home *** CD-ROM | disk | FTP | other *** search
Wrap
Text File | 1993-09-17 | 131.3 KB | 3,585 lines | [ TEXT/MPS ]
######################################################################### # Controls.lib #======================================================================== # Description: This is a library of general Virtual User tasks. All of the # tasks do their own error checking and status/error reporting. # Most of them return a 1 if the action was successful and a 0 # if the action could not be performed. GetNewFileName() returns # a new file name, MatchApp(), the current application's name, # and GetXYRandom, a random X,Y coordinate pair. Tasks that do # not return a value are marked with an *. # The available tasks are listed below in order: # # # Initialization Tasks: # InitControlGlobals() # PrintGlobalValues() # # Logging Tasks: # LogStr(str, LogPriority) # TargetInfo(theList) # MatchApp(logMe,UpdateAppTitle) # # Keyboard Tasks: # TypeStr(str) * # TypeList(List,Key, TypeFinalKey) * # KeyEq(Alias,Otherkey) * # SpecialKey(Key, keyName, numTimes) * # # Control Tasks: # SelectMenuItem(menuName1, menuName2, menuName3) # FindMenu(theMenuItem) # SelectButton(ButtonName) # SelectRadioButton(RadioButtonName) # SelectCheckBox(CheckBoxName) # CheckYesNo(flag) # # Window Tasks: # DialogCheck(FindStaticText, CommitButton, LogIT) # FindWindow(specifier) # SelectWindow(specifier) # DragWindow(h,v,specifier,absolutely) # SizeWindow(X,Y,specifier,absolutely) # ZoomWindow(specifier) # ScrollWindow(foo,x,y) # GetVHScrollBars() # CloseWindow(howClose, overwrite, specifier, DocName) # # Mouse Tasks: # MoveRelativeToWindow(x, y, specifier, mouseDown, inset) * # MoveMouse(x, y, absolutely , mouseDown) * # # File Related Tasks: # NameOK(NameDoc, replaceFlag,SelectSaveAs,PathList) # OpenDoc(namedoc, SelectOpen. PathList) * # SF_Navigate( PathList,TEToggle, FinalReturn) # SF_Type(PathList,TEToggle, FinalReturn) # ReplaceExist( replaceFlag, NameDoc) # GetNewFileName(name) # # Launch Tasks: # Twitcher(appName) # MiniLaunch(appTitle, LaunchApp, SetDir) # LaunchTwitch(AppName, AliasDir, LaunchApp, SetDir) # PatchLaunchTwitcher(AppName, AliasDir, LaunchApp,SetDir) # # String Tasks: # IsSubString(str1, str2) # FindPos(char, str, startPos) # Substring(String,StartChar,NumChar) # # Drawing/Tool Tasks: # DrawShapeFrame(spec, ltrb, inset) # SelToolFromWindow(the_tool, WindSpecifier, WhichToolStr) # SelToolFromPallette(the_tool, WindSpecifier, WhichToolStr) # DoDraw(PaletteType) # DoText (NextLineKey, Specifier, inset) # # Misc. Tasks: # PageSetup(WhichDevice) # Printer() # GetXYRandom(inset, specifier) # IsNumber(whatAmI) # PtInRect(thePoint,theRect) # CenterOfScreenClick() # RemoveItem(Item,list) # ReplaceItem(ItemtoBeReplaced, ReplaceItem,List) # Timer(timeParam) begin # ETime(time1, time2) begin # DoSpecialTest( WhichTest ) # Scrapbook(requestElement, ccpFlag, pasteFlag) * # Quit(OverWrite,DocName,HowQuit) # # Copyright Apple Computer, Inc. 1985-1991 # All rights reserved #=============================================================================== # NJV/KTA 5/23/90 Created version 2.03 # NJV/KTA 7/20/90 Modified to 2.1. - For more info about tasks that # have changed since 2.03 the changes please refer to # the task header. These changes should not affect your # current scripts. The fixes were for added functionality. # Globals were added for disabling individual features of # LogStr. # LogStr() # TargetInfo() (New) # MatchApp() # TypeList() (New) # SpecialKey() # CheckYesNo() # SizeWindow() # ScrollWindow() # GetVHScrollBars() (New) # CloseWindow() # MoveRelativeToWindow() # MoveMouse() # NameOK() # OpenDoc() # Scrapbook() # IsSubString() (New) # FindPos() (New) # DM 9/18/90 Modified to 2.2. - Added DoSpecTest() and calls to include # Cdev.lib.vu and DA.lib.vu # DM 9/24/90 Modified CloseWindw, MoveRelativeToWindow and GetXYRandom. # All calls are preserved except GetXYRandom. Added # general version of DrawShapeFrame. # NJV 10/9/90 Bug fix in Scrapbook for 6.0 world # NJV 11/27/90 Updated to version 2.4b3 by making the following changes: # + Docname wasn't explained in CloseWindow() # + Header for Quit() needed to be fixed # + Header for FindWindow() needed to be fixed # + Header for Opendoc() needed to be fixed # + Header for ScrapBook() needed to be fixed # + Header for NameOK() needed to be fixed # + Full names were taken out of headers # + bug fix and header update in SpecialKey() # + updated LaunchTwitch() and MiniLaunch() for new # version of MiniLauncher 1.3b # NJV/KTA 12/18/90 Combined changes from 2 updated versions of Controls.lib # KTA 12/20/90 Fixed bug in AppVerify scheme which included changes to # LaunchTwitch, LogStr, MatchApp # Also updated NameOK to handle dialog change in 7.0 # KTA 1/2/91 Added global BuildVers. # KTA 1/8/91 Changed Scrapbook, Quit # NJV/KTA 1/24/91 2.5b4 - Modified LaunchTwitch, Added check for warfare, # included Library include of Integrate.lib, added # code to support Integrate library # NJV 1/28/91 Modified LaunchTwitch to disable integration # KTA 2/5/91 Added DialogCheck for checking statictext in Dialogs # KTA 2/18/91 InitControlGlobals() - added outputting of Global values. # Quit() - while(checkYesNo) # ScrapBook() - Global Integration := 0 # LogStr() - Added LineItemTest # LogStr() - Took out Integration if DisableAllLogging # NJV 3/28/91 2.5b5 - Updated Headers, changed LaunchTwitch, # added PrintGlobals() # NJV 6/25/91 Added PtInRect routine, modified ZoomWindow for # better error checking, modified IsNumber to # use VU's new TypeOf function. # KTA 7/10/91 Added Standard File stuff SF_Type and SF_Navigate # Modified NameOK and OpenDoc # Modified GetNewFileName # KTA 7/26/91 global SF_PUTLocation; # global LogLevel; # global PatchLaunchTwitch; # KTA 8/3/91 global ScrapTEXT; # global ScrapPICT; # global AliasDirectory; # Added parameter to PageSetup() # KTA 8/19/91 Added more Globals and DoText Task # DragWindow('RandomReturn'); # KTA 8/21/91 Timer(4) := CurrentTime # KTA 9/05/91 Added Specifier = 0 for DoText # Added Global Printer # KTA 9/17/91 Added ReplaceItem(), RemoveItem(), # SelToolFromWindow(),SelToolFromPallette() # KTA 9/21/91 Updated DoText() - Added FindMenu() # KTA 9/22/91 Updated SelectButton(),SelectCheckBox(),SelectRadioButton() # KTA 10/29/91 Added Global DrawWindow to DoDraw(). # Fixed problem in GetXYRandom() when passing string as Specifier. # KTA 11/15/91 Fixed LaunchTwitch memory check # JM 2/3/92 ZoomWindow: Fixed failure on multiple monitors # JM 2/3/92 CloseWindow: Fixed bogus error on dirty-save. # JM 2/6/92 IsSubStr: Added '=' clause # ML 2/12/92 Updated DoText() - added inset parameter # JM 2/14/92 Fixed Timer(4) for hours between 12AM and 1AM # JM 2/25/92 Twitcher(): Added '~' in 'Hide' exception. # SubString(): Added space between 'Card' and 'String'. # KTA 4/14/92 Removed project specific calls # KTA 4/14/92 Reimplemented 6.0.x launching mechanism (minilaunch) # KTA 4/15/92 Reimplemented 6.0.x Standard File support # KTA 4/20/92 Implemented support for International (ordinality) # ML 4/21/92 FindWindow(): Added error check for screen ordinality # GetXYRandom(): Optimized using FindWindow() # SelToolFromPallette(): Revised for compatibility to VU 2.0 # SelToolFromWindow(): Revised for compatibility to VU 2.0 # DoDraw(): Revised for compatibility to VU 2.0 # ZoomWindow(): Revised for compatibility to VU 2.0 # KTA 4/21/92 Added support for pointlists in MoveMouse(), # MoveRelativeToWindow(), and GetXYRandom() ######################################################################### ######################################################################### #################### GLOBALS ##################### ######################################################################### ### Global Library Definitions ### If current value is 0 or 1, new value must be a 0 or 1 ### If current value is true or false, new value must be true or false ### If current value is a string, new value must be a string ### ######################################################################### ######################################################################### # InitControlGlobals() #======================================================================== # Author: NJV # Description: Initializes all global variables used by the Controls.lib # library. This task should be called immediately after # the "Libaries 'Control.lib';" line in the script. It # is OK to modify the values of some of the variables. This is # how you customize your VU scripting environment and the way # that your scripts will react using this library. # Parameters: None # Returns: Nothing # Examples: InitControlGlobals(); # Assumptions: That you understand what the global does before resetting it. ################################################################################ ########### It is OK to modify the following GLOBAL Settings - Be ########### ########### careful that you understand what the Global is used for ########### ################################################################################ #======================================================================== # History: # NJV 3/28/91 Created ######################################################################### Task InitControlGlobals() begin println "Initializing Globals in the Controls.lib 3.0.15"; ############## Misc Globals ############ global LogLevel := 5; # Specifies the which logstr calls will be output global PatchLaunchTwitch := 0; global BugsOn := 0; # if set to 1 any known bugs which check this global will be regressed global Spectest := 0; # To begin any special tests designated in global AppVerify := 1; # 1 to verify the application is expected global TargetInfoDescriptor := 'Target'; # Descriptor to use 'Target' is the one only defined currently global TargetCheck := 2; # 1 for target title; 2 for target application title ################################# # Value for integration variable sets approximate number of LogStr calls # per Integration call. The ratio of integrate()/LogStr() = 1/Integration. ################################# # Random CDEV/DA testing global Integration := 0; # Integration module requires Integration.lib and ShimSquad.lib # Only call is in LogStr() verify the call is uncommented. ############## Font Globals ############ global FontList := {"Courier","Helvetica","Times"}; global FontSizeList := { '10','12','14','18','24' }; global FontStyleList := { 'Plain','Bold','Italic','Outline' }; global TextStr := "How piqued razorback frogs can level six jumping gymnasts, Jim!"; ############## Tool Global ############ global ToolMultiplier := 1; # Times to excercise an applications tools ############## ScrapBook Globals ############ global ScrapTEXT := 1; # ScrapItem location of TEXT global ScrapPICT := 2; # ScrapItem location of PICT global ScrapStyledTEXT := 0; global ScrapColorPICT := 0; global ScrapICON := 0; global ScrapSOUND := 0; global ScrapMOVIE := 0; ############## Script Globals ############ global AliasDirectory := "#CoreAliases"; # Location of Core app aliases ( found in Apple Menu ) global AliasDirectory2 := "#Tier 1-2 Aliases"; # Location of nonCore app aliases ( found in Apple Menu ) ############################################################################ # SF_PutLocation contains the path to the directory in which files will be saved # by the NameOK task. If the list is empty files will be saved in the default dir # IMPORTANT: SF_PUTLocation is a list # for example: global SF_PUTLocation := {"myDisk"}; ############################################################################ global SF_PUTLocation := {}; ############## Print Global ############ global PrintTest := 0; # If true print test will be executed ############################################################################ ####### DO NOT modify any of the following GLOBAL Settings - ############ ####### DisableAllLogging may be reset during script execution ############ ############################################################################ match[system v:?Sysname]; # Match system build if (Sysname >= /7.0/) Global isSys7 := True; else Global isSys7 := False; global BuildVers := "{Sysname}"; global LogStrCount := 0; # Initializes the counter used by LogStr global LastSavedFile; # Contains the name of the last file saved from NameOK(); global AppTitle := ""; # Current application title for AppVerify() global PrevAppTitle := ""; # Previous application title (for twitching back) global DisableAllLogging := 0; # 1 if no logging (run time modify only) if (global DisableAllLogging) Global LogLevel := 0; global SF_OriginalPath := {}; # Holds pathlist of Standard File before you navigate PrintGlobals(); # print the global values to output println; end; ######################################################################### # PrintGlobals() #======================================================================== # Author: NJV # Description: Prints the values of all Control Globals # Parameters: None # Returns: Nothing # Examples: PrintGlobals(); # Assumptions: None #======================================================================== # History: # NJV 3/28/91 Created ######################################################################### task PrintGlobals() begin global BuildVers; if (global AppVerify) println "The 'Application Verification' scheme is turned - ON"; else println "The 'Application Verification' scheme is turned - OFF"; if (global TargetCheck) begin if (TargetCheck= 1) TCItem := "the target's 'Title'"; else if (TargetCheck= 2) TCItem := "the title of the target's current 'Application'"; println "The global 'TargetCheck' is set to output - {TCItem}"; end; ############## Print Font Globals ############ if (global FontList) begin print "The global 'FontList' is : '"; fntCount := Card(FontList); For timeThru := 1 to fntCount begin print FontList[timeThru]; if not(timeThru = fntCount) Print "', '"; end; Println "'"; end; if (global FontSizeList) begin print "The global 'FontSizeList' is : '"; fntSZCount := Card(FontSizeList); For timeThru := 1 to fntSZCount begin print FontSizeList[timeThru]; if not(timeThru = fntSZCount) Print "', '"; end; Println "'"; end; if (global FontStyleList) begin print "The global 'FontStyleList' is : '"; fntSTLCount := Card(FontStyleList); For timeThru := 1 to fntSTLCount begin print FontStyleList[timeThru]; if not(timeThru = fntSTLCount) Print "', '"; end; Println "'"; end; if (global TextStr) println "The global TextStr is set to - '{TextStr}'"; ############## Print ScrapBook Globals ############ if (global ScrapTEXT) println "ScrapText is set to - '{ScrapTEXT}'"; if (global ScrapPICT) println "ScrapPICT is set to - '{ScrapPICT}'"; if (global ScrapStyledTEXT) println "ScrapStyledTEXT is set to - '{ScrapStyledTEXT}'"; if (global ScrapColorPICT) println "ScrapColorPICT is set to - '{ScrapColorPICT}'"; if (global ScrapICON) println "ScrapICON is set to - '{ScrapICON}'"; if (global ScrapSOUND) println "ScrapSOUND is set to - '{ScrapSOUND}'"; if (global ScrapMOVIE) println "ScrapMOVIE is set to - '{ScrapMOVIE}'"; ############## Print Script Globals ############ if (global AliasDirectory) println "AliasDirectory is set to - '{AliasDirectory}'"; if (global AliasDirectory2) println "AliasDirectory2 is set to - '{AliasDirectory2}'"; if (global ToolMultiplier) println "The global ToolMultiplier is set to - '{ToolMultiplier}'"; ############## Print Other Globals ############ if (global BugsOn) println "The global 'BugsOn' has been activated - Cross your fingers!!!"; if (global Spectest) # DoSpecTestsInitial and DoSpecTestsMiddle println "The SpecialTests are - ON. Does this effect you???"; else println "The SpecialTests are - 'OFF' or Disabled"; if (global Integration) println "Integration Testing is - 'ON' and set to '{Integration}'"; else println "Integration Testing is - 'OFF' or Disabled"; if (global LogLevel) println "LogLevel is set to '{LogLevel}'"; else println "All logging is disabled"; Println "The current system is - '{BuildVers}'"; if (global SF_PUTLocation) begin SFPath := ""; for each item in SF_PUTLocation SFPath := SFPath + Item + ":"; Println "SF_Put is set to navigate to '{SFPath}'"; end; else println "SF_Put will save to the default directory"; end; # PrintGlobals() ######################################################################### # LogStr(str, errorCheck,doTargetCheck) #======================================================================== # Author: KTA # Description: Match the target and print it with whatever is passed # to it in the 'str' parameter. Set the appropriate # LogPriority based on the context of the string. # Parameters: str - string to be printed # LogPriority - The priority of the string to be printed # 0 - No logging # 1 - Errors # 2 - Comments and Notes # 3 - Summary information # 4 - More detailed # 5 - Detailed description # Returns: Nothing # Examples: LogStr("It worked"); # LogStr("It worked",3); # Assumptions: None #======================================================================== # History: # KTA 4/1/90 Created # KTA 4/29/90 This routine now checks to make sure the global # AppTitle equals the current application running - # if not, it assumes that the target crashed and # aborts the script. # NJV 5/15/90 Added errorCheck parameter for disabling error # checking. # NJV 7/9/90 Added targetCheck for disabling target matching # NJV/KTA 7/13/90 Added TargetInfo mechanism # KTA 7/19/90 Added key equivelant 'Q'; to quit the current app if it doesn't match # NJV 7/24/90 Moved LogStrCount into not DisableAllLogging block # KTA 8/2/90 Added - if not( theAppTitle ~= /≈{global AppTitle}≈/) # NJV/KTA 12/18/90 Added - Retry for AppVerify # KTA 12/20/90 Reworked errorCheck to work with new MatchApp # KTA 2/18/91 Added LineItemTest # KTA 2/19/91 Took out integration is DisableAllLogging is on. # KTA 4/1/91 Changed LogStr to Print so we wouldn't recursively call logStr. # KTA 7/26/91 Deleted parameters errorCheck and doTargetCheck (Sorry Nick) # Added LogPriority # KTA 8/5/91 Changed app verification check to call to IsSubString ######################################################################### task LogStr(str,LogPriority := 5) begin global AppVerify, TargetCheck, AppTitle, LogLevel,LogStrCount,DisableAllLogging; theStr := ''; if (TargetCheck) theStr := TargetInfo(TargetCheck); if (not DisableAllLogging) and (LogPriority <= LogLevel) begin LogStrCount := LogStrCount + 1; println LogStrCount," - ",str," {theStr}"; end; if (AppVerify) begin match[application t:?theAppTitle]; retry := 2; while not(IsSubString(AppTitle, theAppTitle)) begin # assume target crashed if app name not match theAppTitle := MatchApp(0,0); if retry begin retry := retry - 1; LaunchTwitch(AppTitle,, 0); end; else begin PressKey K:{CommandKey}; Type k: {'q'}; # Quit ReleaseKey K:{CommandKey}; Println "*** Current application: '{theAppTitle}' *** Expected application: '{AppTitle}'"; Println "*** Assuming the target is off track - aborting script and typing key Equivalent 'Q'"; Println "################### Failure ################"; Println; Println; exit; end; end; end; ######################################### # if we are in integration mode, integrate! (* ######################################### if (global Integration) begin if not(DisableAllLogging) begin if (1 = random(1,Integration)) begin # if the random number is 1, then run integrate() if not(match[window o:1 s:Dialog]!) Integrate(1,-3,1); # perform a random DA or CDEV test end; end; end; *) Return(1); end; # LogStr() ######################################################################### # TargetInfo(theList) #======================================================================== # Author: NJV/KTA # Description: Match whatever is specified in global TargetInfoDescriptor # and will return the appropriate string. # Parameters: theList[1] - what to match for - default 'Target' # theList[2] - Specifier of what info to return # If theList[1] = 'Target'then # if theList[2] = # 1 - Return Title for target # 2 - Returns Application running on Target # Returns: Str # Examples: global TargetCheck := 1; # global TargetCheck :={1,2}; #======================================================================== # History: # NJV/KTA 7/13/90 Created # KTA 9/22/91 Only target info ######################################################################### task TargetInfo(theList) begin theDesc := global TargetInfoDescriptor; list2 := theList; if (not card(list2)) # a single number list2 := {theList}; if (theDesc = 'Target') begin theDescInfo := match [target t:?TargetTitle a:?App]!; theAppTitle :=App[1].t; if not (theDescInfo) return(''); str := "(Target -"; for each item in list2 begin if (item = 1) # title str := "{str} Title:∂'{TargetTitle}∂'"; else if (item = 2) # App str := "{str} Application:∂'{theAppTitle}∂'"; end; str := "{str})"; return(str); end; end; # TargetInfo() ######################################################################### # MatchApp(logMe,UpdateAppTitle) #======================================================================== # Author: KTA # Description: This routine will match the current Application and, # if the logMe parameter is 1, will log the current # application name by passing it to LogStr(). If a # parameter is not passed, the default behavior will # log the application's title. This routine will also # set the global AppTitle to the application's title. # Output appears in the following format: # The current application is "Finder" # Parameters: logMe - 1 to print the current application's title # 0 not to print the application's title # UpdateAppTitle - 1 to update the global AppTitle # - 0 not to update global AppTitle # Return Value: string holding current application's title # Examples: MatchApp(); # Assumptions: there is an active application #======================================================================== # History: # KTA 3/16/90 Created # KTA 4/28/90 Makes a call to global Apptitle to Verify App # KTA 5/7/90 Added parameter to allow bypassing of LogStr() call. # NJV 5/13/90 Now returns title of application # KTA 7/13/90 Took out initial 5 second wait # KTA 12/20/90 Added UpdateAppTitle # KTA 9/22/91 Ability to not update global AppTitle but still log the app ######################################################################### task MatchApp(logMe := 1, UpdateAppTitle :=1) begin match[application t:?theAppTitle]; if (UpdateAppTitle) global AppTitle := theAppTitle; #to Verify App if (logMe) LogStr("The current application is '{theAppTitle}'"); return(theAppTitle); end; # MatchApp() ######################################################################### # TypeStr(str) #======================================================================== # Author: KTA # Description: This routine will type whatever is passed in as the String. # Parameters: str - string to be typed # Returns: Nothing #======================================================================== # History: # KTA 1/20/90 Created # KTA 1/9/91 Added default parameter '' ######################################################################### task TypeStr(str :='') begin type k:{str}; LogStr("Typed '{str}'"); end; # TypeStr() ######################################################################### # TypeList(List,Key, flag) #======================================================================== # Author: KTA # Description: This routine will type each item in the {list} and the # selected special key after each item. If flag = 0 the # special key will be suppressed after the last item. # Parameters: List - list holding strings to type # Key - int representing key to type after the item has # been typed. # key := 0 Nothing # key := 1 (ReturnKey) # Key := 2 (TabKey) # Key := 3 (EnterKey) # Key := 4 (UpArrowKey) # flag - 1 to type special key after last item in list # 0 to disable typing of last special key # Return Value: None # Examples: TypeList({'A','list', 'of items'},2); To type each item # and then the tabKey # Assumptions: None #======================================================================== # History: # KTA 7/1/90 Created # DMM 7/2 Flag to type special key after last item # KTA 8/20/90 Added check to see if key is defined before adding 'and' to {item} # KTA 7/20/91 Check if punctuation of specialkey # KTA 9/04/91 Added UpArrow key # KTA/DM 9/22/91 Reorganized ################################################################################ task TypeList(List,Key := 0, TypeFinalKey := 0) begin theWholeList := card(list); for numtimes := 1 to theWholeList begin if(TypeOf(Key) = 'integer') begin if (key = 1) KeyList := {ReturnKey,' and the Return Key'}; else if (key = 2) KeyList := {TabKey,' and the Tab Key'}; else if (key = 3) KeyList := {EnterKey,' and the Enter Key'}; else if (key = 4) KeyList := {UpArrowKey,' and the Up Arrow Key'}; end; else KeyList := {Key,' and some Special Key???'}; KeyName := KeyList[2]; Item := List[numtimes]; Type k:{ Item }; if not (numtimes = theWholeList) begin Type K:{KeyList[1]}; end; else if(TypeFinalKey) Type K:{KeyList[1]}; else KeyName := ''; LogStr("Typed '{item}'{KeyName}"); end; end; # TypeList() ######################################################################### # KeyEq(Alias,Otherkey) #======================================================================== # Author: KTA # Description: This routine will select the Keyboard Equiv <alias> # Parameters: Alias - string holding character to be typed with # command key down. # OtherKey - int representing special keys to hold down in # conjunction with the command key # 1 - Shift key # 2 - Option key # Returns: None # Examples: KeyEq("q"); #======================================================================== # History: # KTA 4/1/90 Created # KTA 7/31/90 Added MatchApp for 'w' and 'q' # KTA/PF 8/14/90 Added Shift key Functionality # KTA 8/16/90 Added Option key Functionality # KTA 9/22/91 Optimized -took out cases for 'w' and 'q' ######################################################################### task KeyEq(Alias,Otherkey := 0) begin KeyList := { '',''}; if (Otherkey =1) KeyList := {ShiftKey,'-Shift'}; else if (Otherkey = 2) KeyList := {Optionkey,'-Option'}; pressKey k:{ commandKey,KeyList[1]}; type k : { alias }; releaseKey k:{ commandKey,KeyList[1] }; WhichKey := KeyList[2]; LogStr("Pressed the ∂('{alias}'∂) key and the Command{WhichKey} key"); end; # KeyEq() ######################################################################### # SpecialKey(Key,keyName,n) #======================================================================== # Author: KTA # Description: This routine will type whatever SpecialKey is entered # However it will only log the name of the special character # if the special key name is also passed in as a String in # the keyName parameter. # Parameters: Key - the VU key-word for the special key to be typed # keyName - the string name of the special key # n - number of times to type the special key (default = 1) # Returns: Nothing # Examples: SpecialKey(TabKey,"TabKey"); #======================================================================== # History: # KTA 4/25/90 Created # KTA 7/5/90 Added n parameter for number of times to be completed. # NJV 11/27/90 bug fix - if no keyName and n > 1, then str was typed # every time instead of once. Also updated header. # KTA 9/22/91 Added StrExt instead of another if statement ######################################################################### task SpecialKey(Key,keyName:="",numTimes :=1) begin StrExt := ""; for x := 1 to numTimes type k:{ Key }; if (numTimes <> 1) StrExt := "- ({numTimes}) times"; if (keyName ="") LogStr("Typed some special key {StrExt}"); else LogStr ("Typed {keyName} {StrExt}"); end; # SpecialKey() ######################################################################## # SelectMenuItem(menuName1, menuName2, menuName3) #======================================================================= # Author: SL # Description: Selects the menu item by its name. # Parameters: menuName1 := Menu item to be selected. # menuName2 := Menu name if non-hier menu and # Level 2 menu item if hier menu. # menuName3 := "" if non-hier menu. # Menu name if hier menu. # Returns: menuTitle - MenuItem name that selection was successful # 0 - Couldn't select menu item # Notes: Do not have to pass 'menuName2' or 'menuName3' # as a parameter. In that case, default value, "", # will be used. #======================================================================= # History: # SL 4/4/90 Created # KTA 5/16/90 MatchApp Verification # KTA 8/7/90 Return menuTitle # KTA 4/7/92 Support selection by ordinality ######################################################################## task SelectMenuItem(menuName1, menuName2 := "", menuName3 := "") begin if (Typeof(menuName1) = 'string') begin if (menuName3 = "") # Match non-hier menus ourMenuItem := match [menuItem t: menuName1 m:[menu t: menuName2]]; else # Match hier menus ourMenuItem :=match [menuItem t:menuName1 m:[menuitem t:menuName2 m:[menu t:menuName3]]]; end; else begin if not(menuName3) # Match non-hier menus ourMenuItem := match [menuItem o:menuName1 m:[menu o:menuName2]]; else # Match hier menus ourMenuItem :=match [menuItem o:menuName1 m:[menuitem o:menuName2 m:[menu o:menuName3]]]; end; if (ourMenuItem) # Not there begin if (ourMenuItem.e) # enabled begin select ourMenuItem!; menuTitle := ourMenuItem.t; LogStr("Selected the '{menuTitle}' menu item"); return(menuTitle); end; else begin LogStr("!@#$% Menu item {menuName1} is not enabled to select."); return(0); end; end; else begin LogStr("!@#$% Could not find menu item {menuName1} to select"); return(0); end; end; # SelectMenuItem() ######################################################################### # FindMenu(theMenuItem) #======================================================================= # Author: KTA # Description: Returns the Menu(s) in which theMenuItem is contained. # Parameters: theMenuItem := the menuitem to be searched for. # Returns: 0 - Can't match theMenuItem. # {theMenu,""} - for a nonHierarchical menu. # {theHMenuItem, theMenu} - if its hierarchical. # Example: MyMenu := FindMenu('Paste'); #======================================================================= # History: # KTA 9/21/90 Created ######################################################################### task FindMenu(theMenuItem) begin MenuName := match[menuitem t:theMenuItem]; if (MenuName) begin IsMenu := descType(MenuName.m); if (IsMenu = 'menu') begin theMenu := MenuName.m.t; Return({theMenu,""}); end; else If (IsMenu = 'menuItem') begin theHMenuItem := MenuName.m.t; MenuName := match [menuItem t:theMenuItem m:[menuitem t:theHMenuItem m:[menu t:?theMenu]]]; Return({theHMenuItem, theMenu}); end; end; else Return(0); end; # FindMenu() ######################################################################### # SelectButton(ButtonName) #======================================================================== # Author: KTA # Description: This routine will select the button named (ButtonName) # Parameters: ButtonName - string holding name of button to select # Returns: 0 - Couldn't select button # ButtonName - Selected button OK #======================================================================== # History: # KTA 3/20/90 Created # NJV 5/13/90 Added checking to assure button is enabled # DM 7/22/91 Dammit # KTA 9/22/91 One match instead of two ######################################################################### task SelectButton(ButtonName) begin IsButton := match[button t:ButtonName]!; if (IsButton) begin if (IsButton.e) begin Select [button t:ButtonName]!; LogStr("Selected button titled '{ButtonName}'"); return(ButtonName); end; else str := "!@#$% Couldn't select button named '{ButtonName}' because it's not enabled"; end; else str:= "!@#$% There was no button named '{ButtonName}'"; LogStr(str); return(0); end; # SelectButton() ####################################################################### # SelectRadioButton(RadioButtonName) #======================================================================== # Author: KTA # Description: This routine will select RadioButton named (RadioButtonName) # Parameters: RadioButtonName - string name of radio button to select # Returns: 0 - Couldn't select radio button # RadioButtonName - Selected button OK #======================================================================== # History: # KTA 3/20/90 Created # NJV 5/13/90 Added checking to assure radio button is enabled # KTA 9/22/91 One match instead of two ######################################################################### task SelectRadioButton(RadioButtonName) begin IsRadioButton := match [RadioButton t:RadioButtonName]!; if (IsRadioButton) begin if (IsRadioButton.e) begin Select [RadioButton t:RadioButtonName]; LogStr("Selected radio button titled '{RadioButtonName}'"); return(RadioButtonName); end; else str := "!@#$% Couldn't select radio button named '{RadioButtonName}' because it's not enabled"; end; else str:= "!@#$% There was no radio button named '{RadioButtonName}'"; LogStr(str); return(0); end; # SelectRadioButton() ######################################################################### # SelectCheckBox(CheckBoxName) #======================================================================== # Author: KTA # Description: This routine will select CheckBox named (CheckBoxName) # Paramters: CheckBoxName - string name of check box to select # Returns: 0 - Couldn't select check box # CheckBoxName - Selected check box OK #======================================================================== # History: # KTA 3/20/90 Created # NJV 5/13/90 Added checking to assure check box is enabled # KTA 9/22/91 One match instead of two ######################################################################### task SelectCheckBox(CheckBoxName) begin isSelectCheckBox := match [CheckBox t:CheckBoxName]!; if (isSelectCheckBox) begin if (isSelectCheckBox.e) begin Select [CheckBox t:CheckBoxName]; LogStr("Selected check box titled '{CheckBoxName}'"); return(CheckBoxName); end; else str := "!@#$% Couldn't select check box named '{CheckBoxName}' because it's not enabled"; end; else str:= "!@#$% There was no check box named '{CheckBoxName}'"; LogStr(str); return(0); end; # SelectCheckBox() ######################################################################### # CheckYesNo(flag, DocName) #======================================================================== # Author: SL # Description: Checks for dialog boxes with "Yes" (or "OK") and "No" # buttons. If they are found, clicks one of the buttons # depending on the 'flag' parameter. # Parameters: flag - TRUE - Selects "Yes" or "OK" button. # FALSE - Selects "No" button. # DocName - Name that docment will be saved with. # Returns: What is returned by SelectButton #======================================================================== # History: # SL 4/3/90 Created # KTA/NV 7/17/90 Added DocName parameter for Nameok # KTA 4/15/91 took out an arbitrary Returnkey. # KTA 9/22/91 IF statements before matching - so we don't match # when it's unnessecary # KTA 9/26/91 Took out call to NameOK and the DocName parameter # Added return values. Calling routines should call # NameOK based on the return Values if appropriate. ######################################################################### task CheckYesNo(flag := true) begin if ( Flag ) begin yesBtn := match[button t:"Yes" w:[window o:1]]!; okBtn := match[button t:"Ok" w:[window o:1]]!; if (yesBtn) return(SelectButton("Yes")); else if (okbtn) return(SelectButton("OK")); end; else begin noBtn := match[button t:"No" w:[window o:1]]!; if (noBtn) return(SelectButton("No")); end; end; # CheckYesNo() ######################################################################## # DialogCheck(FindStaticText,CommitButton) #======================================================================= # Author: KTA # Description: This routine will to match a dialog of ordinality 1, # with StaticText - {FindStaticText}, if found it will select the # Button - {CommitButton}. # Parameters: FindStaticText - StaticText string that you want to match # CommitButton - Button to select if the static text is found. # Returns: 1 - Found FindStaticText and selected CommitButton # 0 - Couldn't find FindStaticText #======================================================================= # History: # KTA 2/5/91 Created # KTA 2/19/91 # KTA 4/1/91 Added c:false to dialog check # KTA 8/6/91 Added LogIT parameter ######################################################################## task DialogCheck(FindStaticText :='', CommitButton :="", LogIT := 1) begin DialogWin := collect[staticText w:[window o:1 s:dialog c:false]!]!; if (DialogWin) begin for each StaticItem in DialogWin begin theStaticText := StaticItem.t; if not( theStaticText = '') begin if(IsSubString(FindStaticText, theStaticText)) begin if (LogIT) LogStr("Found Dialog: '{theStaticText}'"); if (CommitButton) SelectButton(CommitButton); return(theStaticText); end; end; end; end; else return(0); end; # DialogCheck() ######################################################################### # FindWindow(specifier) #======================================================================== # Author: DM # Description: FindWindow will return the descriptor of the window # specified by the parameter specifier. # Parameters: specifier - if string, then it holds title of window # if integer, then it holds ordinality of window # Returns: 0 - Couldn't find the window # 1 - found the window OK # Example: FindWindow(1); #======================================================================== # History: # DM 9/27/90 Created # NJV 11/27/90 Added documentation # ML 4/8/92 Added error check for screen ordinality if # specifier < 0 ######################################################################### task FindWindow(specifier := "None") begin if(specifier = "None") begin LogStr("Null specifier passed as a parameter to FindWindow"); return (0); end; if not (TypeOf(specifier) = 'integer') begin theDesc := match [window t:specifier]!; if (not theDesc) begin LogStr("!@#$% Couldn't match a window of title {specifier}"); return(0); end; end; else if(specifier > 0) begin theDesc := match[window o:specifier]!; if (not theDesc) begin LogStr("!@#$% Couldn't match a window of ordinality {specifier} with a grow box"); return(0); end; end; else if(specifier = 0) begin theDesc := match[window c:true g:true]!; if (not theDesc) begin LogStr("!@#$% Couldn't match a window with a close and grow box"); return(0); end; end; else if (specifier < 0) begin scrList := collect[screen]!; theDesc := scrList[-specifier]; if (not theDesc) begin scrOrd:=-specifier; LogStr("!@#$% Couldn't match a screen with ordinality {scrOrd}"); return(0); end; end; return (theDesc); end; # FindWindow() ######################################################################## # SelectWindow(specifier) #======================================================================= # Author: NJV # Description: This routine will select a window specified by # ordinality or title. # Parameters: specifier - holds the title or ordinality of window to # select. # Returns: 1 - Selected window OK # 0 - Couldn't find window to select #======================================================================= # History: # NJV 4/7/90 Created # NJV 5/13/90 Condensed two parameters to one # DM 9/27/90 Optimized and added FindWindow # ECH 11/7/90 Changed default parameter to 0 to let FindWindow # do its work. # DM/KA 9/30/91 Let FindWindow() handle errors ######################################################################## task SelectWindow(specifier := 0) begin noErrorFlag := 0; # Init error condition theWind := FindWindow(specifier); if theWind begin windOrd := theWind.o; title := theWind.t; select [window o:windOrd t:title]!; LogStr("Selected window of ordinality {windOrd} (titled '{title}')"); noErrorFlag := 1; end; else LogStr("!@#$% Couldn't select the window"); return(noErrorFlag); end; # SelectWindow() ######################################################################### # DragWindow(h,v,specifier,absolutely) #======================================================================== # Author: KTA # Description: This routine will drag the specified window # 'h' pixels horizontally (-h drags left) and 'v' pixels # vertically (-v drags up) # Parameters: h - Horizontal pixel offset to drag the window # v - Vertical pixel offset to drag the window # specifier - holds title or ordinality of window to drag # absolutely - 1 if absolute drag # 0 if relative drag # Returns: 1 - Dragged window OK # 0 - Couldn't find window to drag #======================================================================== # History: # KA 4/6/90 Created # NJV 4/7/90 Allows for dragging by title or ordinality # NJV 4/26/90 Changed to allow for absolutely or relative drag # NJV 5/13/90 Condensed parameter list # DM 9/27/90 Optimized and added FindWindow # Changed specifier default to 0 so it will match the # first document window. # KTA 8/19/91 Added RandomReturn # DM/KA 9/30/91 Let FindWindow() handle errors ######################################################################### task DragWindow(h := "Random", v := "Random", specifier := 0,absolutely := 1) begin noErrorFlag := 0; # Init error condition if (h = "Random") or (h = "RandomReturn") begin # user wants random coordinates if (h = "RandomReturn") RandReturn := 1; xyRandom := getXYRandom(,-1); h := xyRandom[1]; v := xyRandom[2]; end; theWind := FindWindow(specifier); if (theWind) begin windOrd := theWind.o; title := theWind.t; if (specifier > 0) Str1 := "of ordinality {specifier} "; else if (specifier = 0) Str1 := "with grow and zoom box "; else if( not IsNumber(specifier)) Str1 := ""; if (RandReturn) # Save original coordinates begin origH := theWind.r[1]; origV := theWind.r[2]; end; if (absolutely) begin drag [window o:windOrd t:title]! a:{h,v}; #To drag the window str := "Dragged window {Str1}titled '{title}' to absolute location ∂({h},{v}∂)"; end; else begin drag [window o:windOrd t:title]! r:{h,v}; #To drag the window str := "Dragged window {Str1}titled '{title}' {h} pixels horizontally and {v} pixels vertically"; end; LogStr(str); if (RandReturn) #Move back to orignial location begin drag [window o:windOrd t:title]! a:{origH,origV}; #To drag the window LogStr("Dragged window titled '{title}' back to it's original location at ∂({Origh}, {Origv}∂)"); end; noErrorFlag := 1; end; else LogStr("!@#$% Couldn't drag the window"); return(noErrorFlag); end; # DragWindow() ######################################################################### # SizeWindow(X,Y,specifier,absolutely) #======================================================================== # Author: KTA # Description: This routine will match and resize the specified window. # If only the X and Y parameters are passed, the default # behavior will size the first window containing a grow # and zoom box absolutely. If no parameters are passed, # then the default behavior will generate random # coordinates on the main screen and resize the window # to an absolute size. If the user passes in the string # "random" for x and y and passes 0 for the absolutely # parameter (for a resize relative to current size), # then checks are performed to assure that new size will # not go off of the screen. If it does, the values will # be adjusted so that the largest the window can be sized # is to the border of the screen. # Parameters: X,Y - the Width and Height to resize the window # specifier - title or ordinality of window to be sized # absolutely - 1 if resize window absolute # 0 if resize window relative # Returns: 1 - Resized window OK # 0 - Couldn't resize window # Examples: SizeWindow(200,400); #======================================================================== # History: # NJV 11/20/89 Created # KTA 1/20/90 Implemented LogStr() # NJV 4/26/90 Added byOrdinality, value, and absolutely parameters # NJV 5/14/90 Condensed byOrdinality and value into specifier parameter # NJV 5/15/90 Added random function # NJV/KTA 7/13/90 Bug fix - only checks window for zoom box under default # NJV 7/19/90 Cut routine size in half. # DM 9/27/90 Optimized and added FindWindow # Changed specifier default to 0 so it will match the # first document window. ######################################################################### task SizeWindow(x:="random", y:="random", specifier := 0, absolutely := 1) begin noErrorFlag := 0; theWind := FindWindow(specifier); specifier := theWind.o; title := theWind.t; if (theWind) begin randomFlag := 0; if (x = "random") begin # user wants to size window randomly xyRandom := getXYRandom(,-1); x := xyRandom[1]; y := xyRandom[2]; randomFlag := 1; if (not absolutely) begin # relative - include possible negative values negative := random(0,1); if (negative = 1) begin x := 0 - x; y:= 0 - y; end; end; end; # specifier = ordinality of window to size # title = title of window to size if randomFlag begin # make sure if random numbers were generated that new window size is on screen theWindRect := theWind.r; match [screen r:?theScrnRect]!; if (absolutely) begin # get Top-Left corner coord of window if ((theWindRect[1] + x) > theScrnRect[3]) # x value off of screen - adjust it x := theScrnRect[3] - theWindRect[1]; if ((theWindRect[2] + y) > theScrnRect[4]) # y value off of screen - adjust it y := theScrnRect[4] - theWindRect[2]; end; else begin # size window relative - get Bottom-Right coord of window if (not negative) begin if ((theWindRect[3] + x) > theScrnRect[3]) # x value off of screen x := theScrnRect[3] - theWindRect[3]; if ((theWindRect[4] + y) > theScrnRect[4]) # y value off of screen y := theScrnRect[4] - theWindRect[4]; end; ### the 20 in the equations below must be there. This is to assure that ### the window is not sized below 20 horizontally (the size box is 20 pixels, ### and attempts to size smaller than that will cause VU to display an ### "Out of bounds" error. else begin # negative value - must check against upper-left corner of screen if ((theWindRect[3] + x - 20) < theScrnRect[1]) # x value off of screen x := 20 - theWindRect[3] - theScrnRect[1]; if ((theWindRect[4] + y - 20) < theScrnRect[2]) # y value off of screen y := 20 - theWindRect[4] - theScrnRect[2]; end; end; end; if (absolutely) begin size [window t:title o:specifier g:true ] W:x H:y; #To size the window match [window t:title o:specifier g:true r:?theWindRect]!; x := theWindRect[3] - theWindRect[1]; y := theWindRect[4] - theWindRect[2]; str := "Resized window '{title}' absolute {x} pixels wide and {y} pixels high"; end; else begin if (randomFlag) begin # include negative offsets for random size match [window t:title o:specifier g:true r:?theOrigWindRect]!; size [window t:title o:specifier g:true ] r:{ x, y }; #To size the window match [window t:title o:specifier g:true r:?theWindRect]!; x := theWindRect[3] - theOrigWindRect[3]; y := theWindRect[4] - theOrigWindRect[4]; end; else begin size [window t:title o:specifier g:true] r:{ x, y }; #To size the window match [window t:title o:specifier g:true r:?theWindRect]!; x := theWindRect[3] - x; y := theWindRect[4] - y; end; str := "Resized window '{title}' relative {x} pixels wide and {y} pixels high"; end; LogStr(str); noErrorFlag := 1; end; else LogStr("!@#$% Couldn't size window"); return(noErrorFlag); end; # SizeWindow() ######################################################################### # ZoomWindow(specifier) #======================================================================== # Author: KTA # Description: Selects the zoom box on the requested window. If no # parameters are passed, then the default behavior will # zoom the first window with a zoom box. # Parameters: specifier - holds title or ordinality of window to zoom # Returns: 0 - Couldn't zoom the window # 1 - Zoomed the window OK #======================================================================== # History: # KTA 3/8/90 Created # NJV 4/7/90 Changed name to ZoomWindow and added title parameter # to zoom a window by title instead of ordinality 1 # NJV 4/9/90 Changed title parameter to byOrdinality and specifier # to allow window specification by title or ordinality. # NJV 5/13/90 Condensed parameters to a single parameter # Took out select window call # DM 9/27/90 Optimized and added FindWindow # Changed specifier default to 0 so it will match the # first document window. # NJV 6/25/91 Added check to assure zoom box is on screen # DM/KA 9/30/91 Let FindWindow() handle errors # J Marsh 1/2/92 Fixed zoom-box-on-screen check for multiple monitors # ML 4/21/92 Added parens around PtInRect(theHitPoint,item.r) in # if statement for compatibility with VU 2.0d3 ######################################################################### task ZoomWindow(specifier:= 0) begin noErrorFlag := 0; # Init error condition theWind := FindWindow(specifier); if theWind begin windOrd := theWind.o; title := theWind.t; zoomBox := theWind.z; theRect := theWind.r; # njv - added 6/25/91 theHitPoint := {theRect[3]-20,theRect[2]}; # hit point for zoom box hitPointOffScreen := true; if (specifier > 0) Str1 := "of ordinality {specifier} "; else if (specifier = 0) Str1 := "with a zoom box "; else if( not IsNumber(specifier)) Str1 := ""; if (zoomBox) begin # test to see if zoom box is on screen screenList := collect [screen]!; for each item in screenList begin if (PtInRect(theHitPoint,item.r)) # see if zoom box on screen hitPointOffScreen := false; end; if (hitPointOffScreen) # can't zoom window str := "Couldn't zoom window {Str1}titled '{title}' - zoom box off screen"; else begin # zoom the window zoom [window o:windOrd t:title]!; #To zoom the window str := "Zoomed window {Str1}titled '{title}'"; end; end; else begin str := "No zoom box found in window {Str1}titled '{title}'"; end; LogStr(str); noErrorFlag := 1; # Init error condition end; else LogStr("!@#$% Couldn't zoom window"); return(noErrorFlag); end; # ZoomWindow() ######################################################################## # ScrollWindow(foo,x,y) #======================================================================= # Author: KTA/NJV # Description: This routine will scroll the specified scrollbar on # the active window. # Parameters: foo = 'H' - for horizontal scrollbar # = 'V' - for vertical scrollbar # <x><y> = the fraction x/y # Returns: 0 - Couldn't scroll the scroll bar # 1 - Scrolled the scroll bar # Examples: ScrollWindow('H',1,2) will scroll the horizontal bar 1/2 # Assumptions: That the scrollbars are present. This routine collects # only the first two scroll bars, which are assumed to be # the horizontal and vertical scroll bars. # This routine is not 100% reliable. #======================================================================= # History: # KTA/NJV 11/21/89 Created # KTA 1/20/89 Added Scrapbook Support # KTA 1/20/90 Added LogStr call # KTA 5/14/90 Removed scrapbook Support # Now checks to see if scrolllbars are enabled # NJV 6/25/90 Added random scrolling # NJV 7/5/90 Added GetVHScrollBars call. # NJV 6/25/91 Changed check for enabled. ######################################################################### task ScrollWindow(foo,x:=-1,y:=-1) begin theScrollBars := GetVHScrollBars(); if (not theScrollBars) return(0); # error - couldn't find scroll bars vertical := theScrollBars[1]; verticalDiff := vertical.s; horizontal := theScrollBars[2]; horizontalDiff := horizontal.s; if (foo = 'V') or (foo = 'v') begin if (x=-1) or (y=-1) begin # generate random value x := random(0,verticalDiff[2]); y := verticalDiff[2]; end; if (vertical.e) begin #Test to see if Scrollbars are enabled scroll vertical a:{x,y}; LogStr("Scrolled the vertical scroll bar Absolute ({x}, {y})"); end; else begin LogStr("!@#$% The vertical scroll bar was not enabled to scroll"); return(0); end; end; else begin if (x=-1) or (y=-1) begin # generate random value x := random(0,horizontalDiff[2]); y := horizontalDiff[2]; end; if (horizontal.e) begin #Test to see if Scrollbars are enabled scroll horizontal a:{x,y}; LogStr("Scrolled the horizontal scroll bar absolute ({x}, {y})"); end; else begin LogStr("!@#$% The horizontal scroll bar was not enabled to scroll"); return(0); end; end; return(1); end; # ScrollWindow() ######################################################################## # GetVHScrollBars() #======================================================================= # Author: NJV # Description: This routine will return the vertical and horizontal # scroll bars. # Parameters: None # Returns: 0 - Couldn't find scroll bars # {vertical,horizontal} - list of vertical and horizontal # scroll bars # Examples: scrollBars := GetVHScrollBars(); # Assumptions: Top of vertical scroll bar is at a lower vertical value # that the horizontal (i.e. the top of vertical rect is smaller # than the top of the horizontal scroll bar's rect). #======================================================================= # History: # NJV 6/25/90 Created ######################################################################### task GetVHScrollBars() begin ScrollWindowlist :=collect[scrollbar]; if not (card(ScrollWindowlist)) begin LogStr("!@#$% There were no recognizable scroll bars present"); return(0); end; Rec1 := ScrollWindowlist[1]; Rec2 := ScrollWindowlist[2]; Rec1R := Rec1.r[1]; Rec2R := Rec2.r[1]; if (Rec1R < Rec2R) begin #To determine which scroll bar is Vertical/Horizontal horizontal := Rec1; vertical := Rec2; end; else begin horizontal := Rec2; vertical := Rec1; end; return({vertical,horizontal}); end; ######################################################################### # CloseWindow(howClose, overwrite, specifier,DocName) #======================================================================== # Author: KTA/NJV/DMM # Description: This routine will close the specified window. If no # parameters are passed to this routine, the default behavior # will select the close box of the first window with a close box. # Parameters: howClose - 0 - tries all three ways noted below to close the # window (if needed) # 1 - tries to close window by selecting "Close" menu # item # 2 - tries to close window by typing "Close" menu # item's key equivalent # 3 - tries to close window by selecting window's # close box # overwrite - 0 - will select "No" from a save-changes dialog # if one appears when closing window # 1 - will select "Yes" to save changes # specifier - holds title or ordinality of window to close # DocName - string holding new document name - if overWrite # parameter is 1, then DocName will be used for # naming the file. # Returns: 1 - Closed window OK # 0 - Couldn't find window to close #======================================================================== # History: # KTA/DM 1/20/90 Created # NJV 4/07/90 Changed name from CloseW() and added title parameter # NJV 4/27/90 Changed to call closeOneWindow and added parameters # NJV 5/13/90 Condensed parameters and added CloseOneWindow in-line # KTA/NJV 7/17/90 Added DocName parameter, updated checkYesNo calls # KTA 8/21/90 Fixed bug in closing by specifier-used to close front window # DM 9/24/90 Fixed error meesage for "No window" case. Commented out # extra(?) match window # DM 9/27/90 Optimized and added FindWindow # Changed specifier default to 0 so it will match the # first document window. # ECH 11/5/90 in howClose 3, closed window using ord and theTitle instead # of just theTitle in case two windows have the same name # NJV 11/27/90 Added documentation for DocName # KTA/DM 9/30/91 Rewrote - check to see if window is still open # J Marsh 1/29/92 Reset theTitle after dirty save to eliminate bogus error # ########################################################################### task CloseWindow(howClose := 3,saveFlag := 1,specifier := 0,newDocName :="") begin noErrorFlag := 0; theWind := FindWindow(specifier); # Find the specified window if (theWind) begin # IF - we found the window ord := theWind.o; # make assignments theTitle := theWind.t; if (ord <> 1) begin SelectWindow(ord); # Select the window if it's not the frontmost theWind := FindWindow(theTitle); ord := theWind.o; # Reassign Ord because selection may have changed ordinality end; if (not howClose) # Try all methods until one works howClose := {1,2,3}; else howClose := {howClose}; # Just use the specified method numItems := Card(howClose); for i := 1 to numItems # Execute once if way to close is specified begin # otherwise three times attempting all methods closeMethod := howClose[i]; if (closeMethod = 1) begin # Close with menu item if(SelectMenuItem("Close","File")) noErrorFlag := 1; # Success end; if (closeMethod = 2) begin # Close with key equivelant closeKey := match[menuItem t:"Close"]; if (closeKey.k) begin KeyEq(closeKey.k); noErrorFlag := 1; # Success end; end; if (closeMethod = 3) begin # Close with close box if (theWind.c) begin close [window o:ord t:theTitle c:true]!; LogStr("Selected the close box on window titled '{theTitle}'"); noErrorFlag := 1; # Success end; else LogStr("Couldn't find the close box on window titled '{theTitle}'"); end; if (noErrorFlag) # IF - we had a success i := numItems; # break because window should be closed end; if (noErrorFlag) # IF - we had a success begin if(checkYesNo(saveFlag)) # Check if a 'Save Document??' dialog appeared if(saveFlag) # if the dialog appeared and we want to save if (match[button t:"DeskTop"]!) # check for Standard File begin NameOk(newDocName,true); theTitle := global lastSavedFile; end; end; temp := global LogLevel; # We want our own logging LogLevel := 0; if(FindWindow(theTitle)) # Is the window we just closed still open begin LogLevel := temp; # Reset logging LogStr("!@#$% Sorry, the window - {theTitle} is still open"); noErrorFlag := 0; end; else LogLevel := temp; # Reset logging end; return(noErrorFlag); # Return Result end; # CloseWindow() ######################################################################### # MoveRelativeToWindow(x, y, specifier,mouseDown,inset) #======================================================================== # Author: NJV # Description: This routine will calculate the window's rectangle # and add x and y input parameters to the # rectangle's top-left coordinate point. It will then # move the mouse to that location. The window is # specified by the specifier input parameter. If the # specifier parameter is not present, the default # behavior will move relative to the frontmost window. # Parameters: x - int representing left (x) coord # or List of points. # y - int representing top (y) coord # specifier - holds title or ordinality of window # 0 matches first s:document c:true g:true window # mouseDown - 0 - don't hold mouse key down while moving # 1 - press mouse key down - move - release # 2 - Click after moving - no mouse down during move # x is ptList 3 - MultiDrag (pressmouse - move - move - move - release) # 4 - move - release # x is ptList 5 - MultiClick (click - move - click - move - click) # inset - inset from window rect for GetXYRandom # Returns: Nothing # Examples: MoveRelativeToWindow(12,25); # Assumptions: Assumes there is a window on the screen #======================================================================== # History: # NJV 10/2/89 Created # NJV 5/13/90 Changed thePoint parameter to two parameters (x, y) # NJV 5/22/90 Added specifier parameter # NJV 7/5/90 Added mouseDown and mouseUp parameters for MoveMouse # NJV 7/9/90 Added matchTarget parameter for diabling target matching # KTA 7/17/90 Added MouseDown = 2 - click after move # NJV 7/17/90 Took out matchTarget and mouseUp parameters # DM 9/24/90 Added inset param so it can be passed to GetXYRandom. # Added 0 option for specifier so it will match the # first document window. # DM 9/27/90 Optimized and added FindWindow # KTA 9/22/91 Added final logStr() - it was missing # DM/KA 9/30/91 Let FindWindow() handle errors # KA 4/21/92 Handle PointLists ######################################################################### task MoveRelativeToWindow(x:= 'random', y:= 'random', specifier:=0,mouseDown:=0,inset:= {30,30,30,30}) begin returnVal := 0; # Init error condition if ( x='random') begin # user wants random mouse move xyRandom := GetXYRandom(inset, specifier); x := xyRandom[1]; y := xyRandom[2]; returnVal := xyRandom; end; theWind := FindWindow(specifier); if theWind begin lvWindRect := theWind.r; lvX := lvWindRect[1]; # X = LEFT (the X co-ord) lvY := lvWindRect[2]; # Handle PointList if (typeOF(x) = "list") # Need to move to a list of coordinates begin MoveMouse(x,{lvX,lvY},1,mouseDown); # move to the calculated location returnVal := {lvX,lvY}; end; else begin lvFinalLeft := x + lvX; # calculate absolutely X lvFinalTop := y + lvY; # calculate absolutely Y MoveMouse(lvFinalLeft,lvFinalTop,1,mouseDown); # move to the calculated location returnVal := {lvFinalLeft,lvFinalTop}; end; end; return (returnVal); end; # MoveRelativeToWindow() ######################################################################### # MoveMouse(x, y, absolutely, mouseDown) #======================================================================== # Author: DMM # Description: This routine will move the mouse x,y relative to # it s current location If x and y are absent or # equal to "random", a random move is generated. # Parameters: absolutely - 1 if move absolutely, 0 if relative # x x distance to move mouse # y y distance to move mouse # if x and y are absent or := "random" then a # random move is generated # absolutely - 1 to move to absolute location # 0 to move relative to current location # mouseDown - 0 - don't hold mouse key down while moving # 1 - press mouse key down - move - release # 2 - Click after moving - no mouse down during move # 3 - press mouse key down - move - don't release # x is List 3 - MultiDrag # 4 - move - release # x is List 5 - MultiClick # Returns: Nothing #======================================================================== # History: # DM 4/19/90 Created # NJV 4/26/90 Changed to allow for relative or absolutely moving # NJV 5/13/90 Re-ordered parameters # NJV 7/5/90 Added mouseUp parameter (defaults to original behavior) # NJV 7/5/90 Changed 2 LogStr calls to 1. # NJV 7/9/90 Added matchTarget parameter (LogStr disables target if mouseDown) # KTA 7/17/90 Added MouseDown = 2 - click after move # NJV 7/17/90 Took out matchTarget parameter - used mouseDown and mouseUp # NJV 7/17/90 Took out mouseUp parameter - changed possible values for mouseDown # KTA 4/21/92 Handle pointList ######################################################################### task MoveMouse(x := 'random', y := 'random', absolutely := 1, mouseDown := 0) begin if ( x='random') begin # user wants random mouse move xyRandom := getXYRandom(); x := xyRandom[1]; y := xyRandom[2]; end; if ((mouseDown = 1) or (mouseDown = 3)) PressMouse; #### To Handle PointLists ##### if (typeOF(x) = "list") # Need to move to a list of coordinates begin pointList := x; xOffSet := 0; yOffSet := 0; if (typeOF(y) = "list") # If its relative to window begin # We pass in y as the offset of the window xOffSet := y[1]; yOffSet := y[2]; end; if (mouseDown = 5) # To start the multiClick click; for each pairPoints in pointList begin nuX := pairPoints[1]; nuY := pairPoints[2]; x := nuX + xOffSet; # If relative to window offset y := nuY + yOffSet; # otherwise the offset is 0 if (absolutely) move a: { x, y }; else move r: { x, y }; if (mouseDown = 5) # Click for Multiclick click; end; if (mouseDown = 3) # Finished MultiDrag releaseMouse; end; else begin if (absolutely) begin move a: { x, y }; str := "Moved the mouse to absolute location ∂({x},{y}∂)"; end; else begin move r: { x, y }; str := "Moved the mouse relative ∂({x},{y}∂) to previous position"; end; # release mouse if needed if ((mouseDown = 1) or (mouseDown = 4)) ReleaseMouse; # add mouse down to log string if needed if ((mouseDown = 1) or (mouseDown = 3) or (mouseDown = 4)) str := "{str} with mouse button held down"; # click if needed if (mouseDown = 2 ) begin Click; str := "{str} and clicked"; end; # log it LogStr(str); end; end; # MoveMouse() ######################################################################## # GetXYRandom(inset, specifier) #======================================================================= # Author: SL # Description: Returns a random X and Y coordinate in the specified # screen or window. # Parameters: inset - ltrb inset from scrn or window # specifier > 0 window to find coords in # = O coords in window with s:doc g:true and c:true # < 0 coords in specified screen. Screen numbersta # is negative of specifier. # Returns: xyRandom - List of random X and Y. eg. { x, y } #======================================================================= # History: # SL 4/5/90 Created # NJV 5/13/90 Added scrn parameter # DM 9/23/90 Added option to get random points in front window # DM 9/23/90 Changed so the default is random coords in windows # rather than screen coords. # DM 10/9/91 Let FindWindow handle screens and match failures # Set the default for inset to the global gInset # KTA 4/21/92 Added return of PointList ######################################################################## Task GetXYRandom(inset := { 0,20,20,20}, specifier := 0, numPts := 1) begin theDesc := FindWindow(specifier); pointlist := {}; if(theDesc) begin rect := theDesc.r; if (rect) begin maxX := rect[3] - rect[1] - inset[3]; maxY := rect[4] - rect[2] - inset[4]; for i := 1 to numPts begin xRandom := random(inset[1], maxX); yRandom := random(inset[2], maxY); thePoint := { xRandom, yRandom }; if(numPts > 1) # Do we want a point list pointList := insert(thePoint , i, pointList ); end; if(numPts = 1) # If there is only one return it just like we always have returnVal := thePoint; else # Otherwise return a list of points { {xPt,yPt},{xPt2, yPt2} }; returnVal := pointList; end; else returnVal := 0; end; else returnVal := 0; return(returnVal); end; # getXYRandom() ######################################################################### # NameOK(NameDoc, replaceFlag) #======================================================================== # Author: KTA # Description: This routine will type a name (NameDoc) into the text edit # field. Then it will press the ReturnKey. If there is a # document already named <NameDoc> then this task will check # the replaceFlag. If it is defined as anything but true # it will select NO to 'Replace Existing?' dialog. It will # then type the time (based on a 24 hour clock) after the # name and retype the ReturnKey. The Default is to replace # an existing document with the same name. It will also call # getNewFileName to create a file name if one is not provided. # Parameters: NameDoc - string holding the name to name the document # replaceFlag - 0 to select 'No' to 'Replace Existing' dialog # 1 to select 'Yes' to replace exisiting file. # Returns: string - filename of saved document # Examples: NameOk('Untitled1'); to name the file 'Untitled1' # Assumptions: That the SF_Put dialog is present # A call to SelectMenuItem('Save As', 'File'); should probably # be made prior to calling NameOK() #======================================================================== # History: # KTA 11/20/89 Created # KTA 5/17/90 Added Global LastSavedFile; # KTA 6/1/90 Fixed so that the time will be appended in 7.0 # NJV 6/26/90 Returns filename # KTA 7/13/90 Remove Return 0 if no 'Yes' Button # NJV 7/27/90 Will keep renaming until original filename # KTA 8/2/90 Matches for a dialog # KTA 8/22/90 DisableAllLogging after matching for dialog once. # NJV 11/27/90 Updated documentation for replaceflag. # KTA 12/20/90 Updated for 7.0ß2+ - changes to dialog # KTA 2/25/91 Better check for SF Dialog # KTA 7/10/91 Totally rewrote using SF_Navigate # KTA 7/22/91 Check for replace dialog (VU bug) fix # KTA 4/14/92 Added 6.0x support ######################################################################### Task NameOK(NameDoc := "", replaceFlag := true, SelectSaveAs := False, Pathlist := global SF_PUTLocation) begin global IsSys7; returnVal := 0; if (SelectSaveAs) selectmenuItem("Save As", "File"); # Select the Open MenuItem wait(2); ## Check to see if Standard File is present SF_Dialog := match[window o:1 s:dialog c:false z:false g:false]!; if (SF_Dialog ) begin println; println "############## Standard File - Save ##############"; if (NameDoc = "") nameDoc := GetNewFileName(); #To get a name if (PathList) and (IsSys7) # No navigating in 6.0 SF_Navigate( PathList ,1); TypeStr(NameDoc); # Type the name of the Document SpecialKey(ReturnKey, 'Return Key'); # Accept the SF dialog ## 7.0 and 6.0 have different 'Replace Existing' dialogs ## Determine if Replace Existing Dialog is present ReplaceExisting := collect[button w:[window o:1]]; if (Card(ReplaceExisting) = 2) NameDoc := ReplaceExist(replaceFlag, NameDoc); else DialogCheck("",'Ok'); # Look for other problems global LastSavedFile := NameDoc; LogStr( "The document's name is - '{NameDoc}'"); returnVal := 1; end; else LogStr( "!@#$% The Standard_File dialog is not present"); return(returnVal); end; # NameOK() ######################################################################### # OpenDoc(namedoc,SelectOpen) #======================================================================== # Author: KTA # Description: This routine will select 'Open' from the 'File' menu, type # the string held in the nameDoc parameter, and # then press the returnkey. It will check to see that # the frontmost window's title contains namedoc. If not, # it assumes that the wrong file opened. It will not select # 'Open' if the SelectOpen parameter is 0. # Parameters: namedoc - string name of document to open # SelectOpen - 0 to disable selecting of the 'Open' menu item. # 1 to select 'Open' from the 'File' menu # 2 keyEq - 'o' # Returns: 1 - Document opened OK # 0 - Document not opened OK # Assumptions: Works with SF_Get, but don't have NameDoc be to long # of a string. # Examples: OpenDoc('Untit'); will select a document such as 'Untitled'. #======================================================================== # History: # KTA 3/16/90 Created # KTA 4/25/90 Changed SelectMenuItem to support by name # NJV 6/26/90 Checks to see if window opened is desired window # Added return values # DMM 6/28/90 Accounted for no window open # KTA 9/4/90 Added SelectOpen # NJV 11/27/90 Updated documentation for SelectOpen. # KTA 7/10/91 Rewrote with SF_Navigate # KTA 4/15/92 Reimplemented 6.0x support # KTA 4/16/92 Check to verify SF is no longer present # KTA 4/21/92 (SelectOpen = 2) - keyEq('o'); ######################################################################### Task OpenDoc(namedoc := "", SelectOpen :=1, pathlist :={}) begin global LastSavedFile, IsSys7; returnVal := 0; if(namedoc) begin if (SelectOpen = 1) selectmenuItem("Open", "File"); # Select the Open menuItem else if (SelectOpen = 2) KeyEq('o'); # Keyboard equivelant 'o' for open wait(2); SF_Dialog := match[window o:1 s:dialog c:false z:false g:false]!; if (SF_Dialog ) begin println; println "############## Standard File - Open ##############"; if ( PathList ) and (IsSys7) # No navigating in 6.0 SF_Navigate( PathList ); TypeStr(NameDoc); # Type the name of the file to open SpecialKey(ReturnKey, 'Return Key'); # Accept the dialog Wait(2); #### Check to make sure Standard file is no longer present SF_Dialog := match[window o:1 s:dialog c:false z:false g:false]!; if (SF_Dialog ) begin LogStr("!@#$% Standard File is still present and it shouldn't be"); SpecialKey(escapeKey, "Escape Key"); # Exit (changed from 'cancel' button - intl) returnVal := 0; # Failure end; else begin ### match the top document window (Hopefully the Document that was just opened) RetrievedDoc := match[window g:true z:true t:?DocName]!; # Match the document window if not(RetrievedDoc) LogStr("!@#$% No open window with grow and zoom boxes"); else LogStr("The front document is named '{DocName}'"); ## Is the document the one we expected if (isSubString(namedoc,DocName)) # looks like the right file returnVal := 1; # return O'TAY BUCKWHEAT else LogStr("!@#$% It appears that the wrong file was opened, BuckWheat"); end; end; else LogStr( "!@#$% The Standard_File dialog is not present"); end; else LogStr("!@#$% No file name was specified"); return(returnVal); end; # OpenDoc() ######################################################################### # SF_Navigate(PathList, TEToggle, FinalReturn) #======================================================================== # Author: KTA # Description: Controls the navigation in Standard File. # Assigns a global SF_OriginalPath to the current directory # for return navigation. # Passes all parameters to SF_Type which performs actual navigation. # Parameters: PathList := List of directories beginning with the disk name. # TEToggle := Whether toggling from a text edit field is required # to navigate. # 1 - Toggle # 0 - No toggling required # FinalReturn := Whether to accept the final item in <Pathlist> # Returns: Pathlist #======================================================================== # History: # KTA 7/3/91 Created # KTA Don't build SF_OriginalPath unless navigation is required ######################################################################### task SF_Navigate( PathList :={},TEToggle :=0, FinalReturn := 1) begin # Verify that Standard File is present SF_Dialog := match[window o:1 s:dialog c:false z:false g:false]!; if (SF_Dialog ) begin if (Pathlist) # Path list needs to be specified begin OrigPathList :={}; # Initialize variable match[popup i:?Popupitems]; # match SF popup for x := 1 to (card PopUpItems-1) # Build a Pathlist OrigPathList := insert(PopUpItems[x].t,1,OrigPathList); if (OrigPathList = Pathlist) # Is the current directory the desired directory Pathlist := {}; else if (TypeOf(PathList) = "integer") # return to where you started begin if (PathList = 1) PathList := Global SF_OriginalPath; end; else # Update the gobal SF_OriginalPath SF_OriginalPath := OrigPathList; SFPath := ''; For each item in PathList # For logging purposes - build pathlist SFPath := SFPath + Item + ":"; LogStr( "Standard File Navigation to the path - ∂[{SFPath}∂]",3); SF_Type(PathList,TEToggle, FinalReturn); Return(pathlist); end; else LogStr( "Standard File is set to current default directory",3); end; else begin LogStr( "!@#$% The Standard_File dialog is not present"); return(0); end; end; # SF_Navigate() ######################################################################### # SF_Type(PathList, TEToggle, FinalReturn ) #======================================================================== # Author: KTA # Description: Performs navigation in Standard File. # Selects the 'DeskTop' button. Then types each item in <PathList> # folled by a returnKey. # Parameters: PathList := List of directories beginning with the disk name. # TEToggle := Whether toggling from a text edit field is required # to navigate. # 1 - Toggle # 0 - No toggling required # FinalReturn := Whether to accept the final item in <Pathlist> # Returns: Nada #======================================================================== # History: # KTA 7/3/91 Created ######################################################################### task SF_Type(PathList,TEToggle :=0, FinalReturn := 1) begin SelectButton('Desktop'); # Start from top if (TEToggle) type k:{TabKey}; # Makes directory list active wait(2); TypeList(PathList,1,FinalReturn); # Actual navigation if (TEToggle) type k:{TabKey}; # Makes text edit active end; # SF_Type() ######################################################################### # ReplaceExist( replaceFlag,NameDoc) #======================================================================== # Author: KTA # Description: Handles the 'Replace existing?' dialog. # Parameters: ReplaceExist := Whether to Replace a document with the same name # or generate a unique name. # 1 - Overwrite document with same name. # 0 - Do not overwrite. Generate unique name. # NameDoc := Name of file which already exists on disk. # Returns: NameDoc ( will be identical to the initial one if replaceFlag is set. #======================================================================== # History: # KTA 6/30/91 Created # KTA 4/15/92 Updated to handle 6.0x and 7.0 # 6.0 and 7.0 have different 'Repalce Existing' dialogs ######################################################################### Task ReplaceExist( replaceFlag := true, NameDoc :='') begin println " -- Replace Existing?? --"; # Different button names on dialog if(global IsSys7) # is System 7 or greater running begin ReplaceString := "Replace"; CancelString := "Cancel"; end; else # Must be 6.0 begin ReplaceString := "Yes"; CancelString := "No"; end; NewSuffix := ""; if (replaceFlag) # Want to replace SelectButton(ReplaceString); else begin # Don't want to replace SelectButton(CancelString); TimeString := GetNewFileName(nameDoc); nameDoc := "{NameDoc}{TimeString}"; if(IsSys7) # 7.0 and 6.0 handle text entry differently in SF type k:{rightArrowKey}; # Places I beam after existing text in SF text edit TypeStr("{TimeString}"); # append time to NameDoc in 6.0/7.0 SpecialKey(returnKey, 'Return key'); end; return(NameDoc); end; # ReplaceExist() ######################################################################### # GetNewFileName(name) #======================================================================== # Author: SL # Description: Gets a new file name by concatenating the app name and # the current time. # Parameters: name - If this parameter is present, this routine will # only pass back the time. If this parameter is not # present, then this routine will pass back a string # consisting of the application name with the time # appended to it. # Returns: newFileName - string name for new file name # or just a time and Sec string #======================================================================== # History: # SL 4/3/90 Created # KTA/DM 4/25/90 Reworked the whole thing # KTA 8/17/90 Added default parameter so wouldn't recieve error message # KTA 7/12/91 Now returns filename appended with Time and Sec. # KTA 4/15/92 If not System 7 will only return Time and Sec. # 7.0 and 6.0 handle text entry differently in SF # KTA 4/15/92 Returns Time and Sec if includeNameFlag is not true ######################################################################### Task GetNewFileName(name :="",includeNameFlag := 0) begin Global IsSys7; match [time h:?Tm s:?Sc]; if (name) begin if(includeNameFlag) newFileName := "{name} {Tm}{Sc}"; else newFileName := " {Tm}{Sc}"; end; else begin match [Application t:?appName]; newFileName := "@{appName}-{Tm}{Sc}"; end; return(newFileName); end; # GetNewFileName() ######################################################################### # Twitcher(appName) #======================================================================== # Author: DM # Description: This task is intended to select apps from the Process List # menu in System 7.0. Use LaunchTwitch to handle launching # or twitching applications. # This routine selects apps from the Process List. # Parameters: appName - app to twitch to. # Returns: 0 if twitching to appName fails # TheCurrentApp - if twitching was successful # Examples: Twitcher("MacWrite 5.0"); # Assumptions: None #======================================================================== # History # DMM 5/29/90 created # DMM 6/26/90 streamlined and updated for a11 # DMM/KTA 7/31/90 Single twitch and 6.0 compat # KTA 12/20/90 Made the Hide check ! # NJV 4/15/91 Added fix for special chars in app name # KTA 8/7/91 Changed logging # KTA 9/26/91 Took out cycling thru the Process List. # JM 2/25/92 Added '~' in 'Hide' exception. ######################################################################### task Twitcher(appName := "") begin if (Global isSys7) match[menuItem t:"Hide Others" m:[menu o:?menuOrd] ]!; ApplicationMI := match[menuItem t:/≈{appName}≈/ m:[menu o:menuOrd] ]!; if not ( ApplicationMI ) # for special chars in appname ApplicationMI := match[menuItem t:appName m:[menu o:menuOrd] ]!; if ( ApplicationMI ) begin if not(ApplicationMI.t ~= /Hide≈/!) begin select ApplicationMI; AppName := ApplicationMI.t; LogStr("Twitched to {AppName} by way of the process list",3); wait(2); TheCurrentApp := matchApp(1); if(isSubString(appName,TheCurrentApp)) #Check to see if App is frontmost return(TheCurrentApp); else return(0); end; end; else begin LogStr("Sorry Charlie, Couldn't select '{appName}' from the process list"); return(0); end; end; # Twitcher() ######################################################################### # MiniLaunch(appTitle, LaunchApp, SetDir) #======================================================================== # Author: NJV - DMM # Description: This routine will launch an application on the target # machine(s). The miniLauncher tool should be the running # application on the target machine(s). This routine will # type the input parameter appTitle to the target machine # and then type the return key (which is how an application # is launched using miniLauncher.) The application to be # launched must reside in a folder beneath the miniLauncher # tool in the directory hierarchy. For more information on # the miniLauncher tool, see the read-me that accompanies # the tool. # MiniLauncher can also open or print documents. See the # LaunchApp parameter description below for more details. # # Parameters: appTitle - title of the application or document to be launched. # The title does not have to be complete. The MiniLauncher # tool will launch the first application it finds # starting with the string appTitle. If LaunchApp # parameter is not 1, then appTitle will hold the # document name to be opened or printed. # LaunchApp - 1 to launch application # 0 to launch application via a document # -1 to print a document (launch app and print) # SetDir - 1 to set the default directory to that of the # application # 0 to bypass setting of default directory (will # end up being MiniLauncher's directory). # # Returns: 1 - Launched OK # 0 - Couldn't launch application (usually due to lack of # enough memory on the target machine). # # Examples: MiniLaunch('Word'); #======================================================================== # History: # NJV-DMM 6/21/90 Created # NJV 11/27/90 Updated for MiniLauncher v.1.3b - added LaunchApp # and SetDir paramters # KTA 4/14/92 Reimplemented ######################################################################### task MiniLaunch(appTitle, LaunchApp := 1,SetDir := 1) begin returnVal := 0; if not(match[window t:"MiniLauncher" o:1]!) begin MiniLauncher := match[menuitem t:/MiniLauncher≈/ m:[menu t:'']]; # is it in the Apple menu if (MiniLauncher) # if so select it begin select MiniLauncher; LogStr("Selected Minilauncher"); returnVal := 1; end; else LogStr("MiniLauncher is not currently running"); end; else returnVal := 1; # Minilauncher is the front window if(returnVal) begin Println " -- MiniLauncher --"; # So log reflects what is going down # if LaunchApp is 0 check for newest version of MiniLauncher foo := match [button t:'Options']!; if (LaunchApp <> 1) begin if (not foo) begin if (LaunchApp = -1) # user trying to print document LogStr("Wrong version of MiniLauncher for printing documents - use v1.3b or newer."); else LogStr("Wrong version of MiniLauncher for launching documents - use v1.3b or newer."); end; else SelectButton('Options'); if (LaunchApp = -1) # user wants to print document SelectRadioButton('Print Document'); else SelectRadioButton('Open Document'); SelectButton("OK"); end; else if (foo) begin SelectButton('Options'); SelectRadioButton('Launch Application'); if (SetDir) SelectRadioButton("Application∂'s Directory"); else SelectRadioButton("MiniLauncher∂'s Directory"); SelectButton('OK'); end; TypeStr(appTitle); SpecialKey(returnKey , "Return Key"); if(DialogCheck("An error has occurred", 'OK')) begin returnVal := 0; DialogCheck('','OK'); # Any additional dialogs end; if(returnVal) MatchApp(0); end; return(returnVal); end; # MiniLaunch() ######################################################################### # LaunchTwitch(AppName, AliasDir, LaunchApp, SetDir) #======================================================================== # Author: KTA # Description: This routine determines whether the Operating system is # 6.0x or 7.0x and launches the application accordingly. # 6.0x - Will check the Apple menu to see if the App is # currently running and select it if it is. If it is not running # it will select Mini from the Apple menu and call MiniLaunch(AppName); # 7.0x - Will check the ProcessList to see if the App is # currently running and select it if it is. if it is not it will # Select the Apple from the Apple Menu, or the <AliasDir> and then type # the <AppName> and select the Open menuItem. # Parameters: AppName - Application to be launched/Twitched # AliasDir - Folder in the Apple menu that contains <AppName>. # LaunchApp - 0 Select from Process list - Do not launch the App. # 1 Select from Process list or launch the App if # necessary. # Returns: 0 - App did not launch # 1 - App launched fine # 2 - App launched with minimum memory # Examples: LaunchTwitch('MacWrite', "#CoreAliases"); # LaunchTwitch('MacWrite Doc',"#CoreAliases",0); # Assumptions: 7.0x - That the Application (or Alias) is resident in the # Apple Menu or the <AliasDir> which contains <AppName> is. #======================================================================== # History: # KTA 7/31/90 Created # KTA 8/2/90 Added- if not( CurrApp.t ~= /≈{AppName}≈/) # DM 9/23/90 Added- Timer() # NJV 11/27/90 Added LaunchApp and SetDir parameters # KTA 12/10/90 Added-match /≈{AliasDir}≈/ instead of "{AliasDir}" # KTA 12/17/90 Added-match Check for error dialogs # NJV/KTA 12/18/90 Added-BailFlag # KTA 12/20/90 LaunchApp 1 - for 7.0 Finder launch on # 0 - Finder launch off # KTA 1/8/90 Removed Timer() # KTA 1/9/90 Changed Exits to Return(0) # NJV 1/23/91 Returns 1 if app launch OK, 2 if launch in min mem # NJV 1/27/91 Disables Integration Module # KTA 2/5/91 Changes loop 10 times to loop 2 times # KTA 2/24/91 Reset Global AppVerify befroe returning values - bug # KTA 2/25/91 /≈{AliasDir}≈/ to see if correct folder is open # KTA 2/25/91 DialogCheck for memory. # NJV 3/27/91 Added check for 6.x to see if MiniLauncher is # current application. # NJV/KTA 4/1/91 Shortened and simplified # NJV/KTA 4/8/91 Return 0 if DialogCheck finds memory dialog. # KTA 7/18/91 Changed the AliasDir open check # KTA 7/26/91 Added PatchLaunchTwitch # KTA 8/7/91 Added more logging # KTA 9/30/91 Changed verification of AliasDirectory # KTA 11/15/91 Changed memory check to include carriage returns. # KTA 4/14/92 Reimplemented 6.0x support ######################################################################### Task LaunchTwitch(AppName, AliasDir :="",LaunchApp := 1) begin global IsSys7; returnVal := 0; Match[application t:?CurrApp]; if not( CurrApp ~= /≈{AppName}≈/) # if its not the current App begin tempTypeSpeed := typespeed(50); global AppVerify, AppTitle, PrevAppTitle, Integration; Temp := AppVerify; PrevAppTitle := AppTitle; # Set previous app to the current app AppVerify := 0; # Turn off Application Verification scheme tempIntegrate := Integration; Integration := 0; # Turn off any CDEV or DA testing during launch if not (Global PatchLaunchTwitch) # if we want to patch Launchtwitch begin # Is it in the Apple Menu ? if (match[menuItem t:/≈{AppName}≈/ m:[menu t:""]]) begin Selectmenuitem("{appName}", ""); # Select it if it's an Apple MenuItem returnVal := 1; end; else # Not in Apple Menu begin if (IsSys7) # System 7 branch begin launchedByProcessList :=Twitcher(Appname); if ((not launchedByProcessList) and (LaunchApp)) # if App is not already running in the Background begin if (AliasDir) # If a folder in the Apple Menu contains our App begin SelectMenuItem(AliasDir, ""); # Select the Folder Wait(2); if (FindWindow(/≈{AliasDir}≈/)) # Is the right folder open begin typeStr("{appName}"); # Type the appName SelectMenuItem('Open','File'); # Select the Open menu item LogStr("Launched/Opened - '{AppName}'",3); DialogCheck("",'Ok'); # Verify that no problems (like alias not found) returnVal := 1; end; else begin LogStr("!@#$% Couldn't open folder titled {AliasDir} containing requested Alias."); DialogCheck(/memory≈(≈∂n≈)*/,'OK'); # Check for memory problems end; end; else LogStr("!@#$% Couldn't launch - '{AppName}'"); end; # not LaunchByProcessList else returnVal := launchedByProcessList; end;# IsSys7 else # Must be a 6.0.x System so we will launch with minilauncher returnVal := Minilaunch(AppName); # System 6 branch end; # Not in Apple Menu end; # Not Global PatchLaunchTwitch else returnVal := (PatchLaunchTwitcher(AppName, AliasDir,LaunchApp)); # Memory Checks if (returnVal) # we're OK so far - keep checking begin for foo := 1 to 2 if(DialogCheck(/memory≈(≈∂n≈)*/,'OK')) # Check for memory problems returnVal := 0; wait(3); # Allow app to launch if there is available memory end; ## Check to insure application actually launched Match[application t:?CurrAppl]; Match[window o:1 t:?CurWin]; # 6.0 support Da's are not applications if ( CurrAppl ~= /≈{AppName}≈/) or ( CurWin ~= /≈{AppName}≈/) begin matchApp(0); # To update the Global gAppTitle to the new App returnVal := 1; end; else # Desired application is not running returnVal := 0; # Reset the global values to there orignial values. AppVerify := temp; typespeed(tempTypeSpeed); Integration := tempIntegrate; end; # if not( CurrApp ~= /≈{AppName}≈/) else # Desired App must be running begin AppTitle := CurrApp; # Update the global gAppTitle returnVal := 1; end; return(returnVal); end; # LaunchTwitch(); ######################################################################### # PatchLaunchTwitcher() #======================================================================== # Author: KTA # Description: # Parameters: # Returns: # Examples: # Assumptions: #======================================================================== # History: # KTA 7/28/91 Created ######################################################################### task PatchLaunchTwitcher(AppName, AliasDir :="",LaunchApp := 1) begin # write your own launching mechanisms - set global patchLaunchTwich to true end; ######################################################################### # IsSubString(str1, str2) #======================================================================= # Author: SL # Description: Checks to see if str1 is in str2. # Parameters: str1 := Substring to be searched for. # str2 := String. # Returns: 0 := str1 is not in str2. # 1 := str1 is in str2. #======================================================================= # History: # SL 6/20/90 Created # KTA 9/4/90 Rewrote # JM 2/6/92 Added '=' clause to allow exact matching to # preclude subStr, which may contain special # characters (parens, '+', etc.) ######################################################################### task IsSubString(str1, str2) begin if (str2 = str1) or ( str2 ~= /≈"{str1}"≈/) return(1); else return(0); end; # isSubString() ######################################################################### # FindPos(char, str, startPos) #======================================================================= # Author: SL # Description: Finds the first occurence of char in str starting # from startPos. # Parameters: char := A character to be searched for. # str := String. # startPos:= Starting position to be searched. # Returns: 0 := Char is not in str starting from # startPos. # pos := Char position of its first occurence # starting from startPos. #======================================================================= # History: # SL 6/20/90 Created ######################################################################### task FindPos(char, str, startPos:= 1) begin numStr := card str; # If start position is greater than the string length, return 0 # if (startPos > numStr) return(0); for i:= startPos to numStr do begin if (char = str[i]) return(i); end; # for return(0); end; # findPos() ######################################################################### # Substring(String,StartChar,NumChar) #======================================================================= # Author: PF # Description: returns the first NumChar characters of the passed String # starting at StartChar. # Parameters: String - String to use # StartChar - Character to start making substring from # NumChar - Integer number of characters to return # Returns: string # Assumptions: none #======================================================================= # History: # PF 8/23/90 Created # PF 8/27/90 Updated to handle begin anywhere in string # JM 2/25/92 Added space between 'Card' and 'String'. ########################################################################## task Substring(String,StartChar,NumChar) begin # first see if number of characters is greater then length of string # and return the whole end of the string if it is. if (NumChar > ((card String) - StartChar + 1)) begin return (Substring (String,StartChar,((card String) - StartChar) +1)); end; else begin # create a string of first NumChar characters and return it. NewString:=""; #start with an empty string for CharCount :=StartChar to ((StartChar + NumChar) - 1) NewString := NewString + String[CharCount]; return (NewString); end; end; #Substring task ######################################################################## # DrawShapeFrame(specifier := 1,ltrb) #======================================================================= # Author: DMM # Description: Click drags a rectangular frame in the specified window. # Parameters: specifier window to draw in; defaults to ordinality 1 # ltrb {"random"} or {l,t,r,b} of rect to draw # inset defines the drawing area relative to the # window rectangle # Returns: nada #======================================================================= # History: # DM 5/22/90 created # DM 9/24/90 Use GetXYRandom to get coords, change # ltrb param to a list. Addd inset param # so it can be passed to GetXYRandom. # DM 9/24/90 Generalized and rolled into control.lib ######################################################################### task DrawShapeFrame(spec := 1,ltrb := {"random"},inset := {0,0,0,0}) begin temp := global DisableAllLogging; global DisableAllLogging := 1; mTemp := mouseSpeed(10); if (ltrb[1] = "random") # get random coordinates for the rect begin lrel := "random"; rRel := "random"; end; else # set specific coordinates for the rect begin lRel := ltrb[1]; tRel := ltrb[2]; rRel := ltrb[3]; bRel := ltrb[4]; end; # do the drag lT := MoveRelativeToWindow(lRel,tRel,spec,0,inset); rB := MoveRelativeToWindow(rRel,bRel,spec,1,inset); mouseSpeed(mTemp); global DisableAllLogging := temp; left := lT[1]; top := lT[2]; right := rB[1]; bott := rB[2]; LogStr("Click-Dragged frame from ∂({left},{top}∂) to ∂({right},{bott}∂)."); end; ######################################################################### # SelToolFromWindow(the_tool,specifier,WhichToolStr) #======================================================================== # Author: DMM # Description: This task selects tools that are embedded in document # windows # Parameters: the_tool - tool position in palette counting left to right, # top to bottom # specifier - ordinality of doc window containing tools # WhichToolStr - String name of tool # Returns: 1 - selected tool # 0 - couldn't select tool # Assumptions: Tools are selected from the front window, tool rectangles # are the same size # as a window. # Examples: SelToolFromWindow(1,2); #======================================================================== # Revisions: # created 6/1 # 9/6/91 KTA Added WhichToolStr for output purposes # 4/8/92 ML Changed variable named 'tool' to 'the_tool' for # compatibility with VU 2.0 # 4/8/92 ML Changed (the_tool mod toolsAcross != 0) # to (the_tool mod toolsAcross = 0) for # compatibility with VU 2.0 ######################################################################### task SelToolFromWindow(the_tool,WindSpecifier := 0, WhichToolStr :='') begin global specifier, toolsAcross, toolsDown, toolRect; if (WindSpecifier) specifier := WindSpecifier; else if not(specifier) specifier := 1; if not (toolRect) begin LogStr("NOTE: Tool globals are not set up correctly",2); noErr := 0; end; else begin DWindow := match [window o:specifier r:?windRect]!; Str1 := "Could not find a window with ordinality '{specifier}'"; if DWindow begin xMove := (toolRect[3] - toolRect[1])/toolsAcross; yMove := (toolRect[4] - toolRect[2])/toolsDown; xStart := windRect[1] + toolRect[1] - xMove/2; yStart := windRect[2] + toolRect[2] - yMove/2; if (the_tool < toolsAcross) xTool := the_tool * xmove; else begin if ((the_tool mod toolsAcross) <> 0) xTool := ((the_tool mod toolsAcross)) * xMove; else xTool := ((toolsAcross)) * xMove; end; if (the_tool mod toolsAcross = 0) yTool := (the_tool/toolsAcross) * yMove; else yTool := (the_tool/toolsAcross +1) * yMove; xTool := xTool + xStart; yTool := yTool + yStart; move a: {xTool, yTool}; click; if (WhichToolStr) Str1 := "Clicked on the '{WhichToolStr}' tool - number {the_tool} at ∂({xTool},{yTool}∂)"; else Str1 := "Clicked on tool number {the_tool} at ∂({xTool},{yTool}∂)"; noErr := 1; end; else begin noErr := 0; end; LogStr(Str1); end; return noErr; end; # SelToolFromWindow() ######################################################################### # SelToolFromPallette(the_tool,specifier,WhichToolStr) #======================================================================== # Author: DMM # Description: This task selects tools from palettes that VU sees as # separate windows # Parameters: the_tool - tool position in palette counting left to right, # top to bottom # specifier - holds title or ordinality of palette window # WhichToolStr - String name of tool # Return Values: 1 - selected tool # 0 - couldn't select tool # Assumptions: Tool rectangles are the same size, VU can see the palette # as a window (tear off menus are torn off). # Examples: SelToolFromPallette(1); #======================================================================== # Revisions: # created 6/1 # 9/6/91 KTA Added WhichToolStr for output purposes # 4/8/92 ML Changed variable named 'tool' to 'the_tool' for # compatibility with VU 2.0 # 4/8/92 ML Changed (the_tool mod toolsAcross != 0) # to (the_tool mod toolsAcross = 0) for # compatibility with VU 2.0 ######################################################################### task SelToolFromPallette(the_tool,WindSpecifier := 0, WhichToolStr :='') begin global specifier, toolsAcross, toolsDown, headerHeight; if (WindSpecifier) specifier := WindSpecifier; else if not(specifier) specifier := 1; if not (headerHeight) begin LogStr("NOTE: Tool globals are not set up correctly",2); noErr := 0; end; else begin if (specifier > 0) begin # specifier = ordinality DWindow := match [window o:specifier r:?windRect]!; Str1 := "Could not find a palette of ordinality {specifier}"; end; else begin # specifier = title DWindow := match [window t:specifier r:?windRect]!; Str1 := "Could not find a palette titled '{specifier}'"; end; if DWindow begin xMove := (windRect[3] - windRect[1])/toolsAcross; yMove := (windRect[4] - windRect[2] - headerHeight)/toolsDown; xStart := windRect[1] - xMove/2; yStart := windRect[2] - yMove/2 + headerHeight; if (the_tool < toolsAcross) xTool := the_tool * xmove; else begin if ((the_tool mod toolsAcross) <> 0) xTool := ((the_tool mod toolsAcross)) * xMove; else xTool := ((toolsAcross)) * xMove; end; if (the_tool mod toolsAcross = 0) yTool := (the_tool/toolsAcross) * yMove; else yTool := (the_tool/toolsAcross +1) * yMove; xTool := xTool + xStart; yTool := yTool + yStart; move a:{xTool, yTool}; click; if (WhichToolStr) Str1 := "Clicked on the '{WhichToolStr}' tool - number {the_tool} at ∂({xTool},{yTool}∂)"; else Str1 := "Clicked on tool number {the_tool} at ∂({xTool},{yTool}∂)"; noErr := 1; end; else begin err := 0; end; LogStr(Str1); end; return err; end; # SelToolFromPallette() ######################################################################### # DoDraw() #======================================================================== # Author: DM (x41220) # Description: Selects drawing tool and uses it. # Parameters: PaletteType - Type of palette # 1 - Palette is a part of document window # 2 - Palette is it's own window # Returns: Nothing # Examples: DoDraw(); # Assumptions: That the application sets up the appropriate globals # ( see SelToolFromWindow or SelToolFromPalette # Global ToolMultiplier,ToolList,Inset,Specifier,ToolRect, # ToolsAcross,ToolsDown,HeaderHeight) # if SelToolFromWindow() - HeaderHeight is not defined # if SelToolFromPalette() - ToolRect is not defined # Applications: #======================================================================== # History: # 9/19/91 KTA Added global ToolMultiplier # 10/29/91 KTA Added global DrawWindow # 4/8/92 ML Changed variable named 'tool' to 'the_tool' for # compatibility with VU 2.0 ######################################################################### task DoDraw(PaletteType := 1) begin Global ToolMultiplier,ToolList,Inset,Specifier,ToolRect,ToolsAcross,ToolsDown,HeaderHeight,DrawWindow; if not(DrawWindow) DrawWindow := 0; numTools := card(toolList); NumShapes := numTools * ToolMultiplier; LogStr("--------- Preparing to draw {NumShapes} random shapes -------",3); for x := 1 to NumShapes begin the_tool := random(1,numTools); if (PaletteType = 1) # Tool palette is part of document window SelToolFromWindow(toolList[the_tool],,'Random'); # select a random tool else if (PaletteType = 2) # Tool palette is a seperate window SelToolFromPallette(toolList[the_tool],,'Random'); # select a random tool DrawShapeFrame(DrawWindow,,inset); # draw in a random frame in Global DrawWindow end; end; ######################################################################### # DoText (NextLineKey, Specifier, inset) #======================================================================== # Author: ML # # Description: This routine will choose a random font size (from global fontSizeList) # and multiple random font styles (from global fontStyleList) for each of # the fonts in the global fontlist. The text defined in the global TextStr, # followed by the chosen font, size and styles will then be typed. # It will then either type the key required to move to the next line, # or move to a random position and click. # # Parameters: NextLineKey - How to move to the next line # 0 Pointer will randomly move and click # 1 Return Key - DEFAULT # 2 Enter Key # 3 Down Arrow Key # 4 Tab Key # Specifier - Use if 0 is passed to NextLineKey. Holds title or ordinality of # window to randomly move and click in. Default is "Untitled". # Inset - Use if 0 is passed to NextLineKey. Inset from window rect for # MoveRelativeToWindow. Default is {30,30,30,30}. # # Returns: none # # Examples: DoText (0) # # Assumptions: This routine cannot be used if names, sizes or styles are chosen via dialog box # (i.e. Excel). # # Your script places the cursor in the starting position where you want the first # text string to be typed before you call DoText(). If you are passing 0 to # NextLineKey (you want pointer to randomly move and click), you script must choose # the text tool, close all tool palette windows, and click in the starting position # where you want the first TextStr to be typed before you call DoText(). # # Some apps (i.e. Pagemaker and Works) use the menu item “Normal” instead of “Plain” # in describing font style. Is these cases, you must replace the correct # menuitem name with a call to ReplaceItem(). for example: # Global FontStyleList := Replaceitem('Plain', 'Normal', FontStyleList); #======================================================================== # History: # ML 8/16/91 Created # KA 9/04/91 Added Specifier # KA 9/21/91 Added call to Find Menu to save location of menus # Also changed functionality to type the global textStr # for each item in the global fontlist and choose a random # size and style. Styles will not be double selected for any # one text string. # ML 2/12/92 Added inset parameter ######################################################################### task DoText(NextLineKey := 1, Specifier := 0, inset:= {30,30,30,30}) begin Global fontList,fontSizeList,fontStyleList,textStr; numFontSize := card(fontSizeList); #counts number of sizes in fontSizeList numFontStyle := card(fontStyleList); #counts number of styles in fontStyleList println; LogStr(" =========== DoText - Font tests ==========="); FontMenu := FindMenu(fontList[1]); # Find the menus - Hierarchy or not StyleMenu := FindMenu('Bold'); # Save the Menu descriptors so we don't have to SizeMenu := FindMenu(fontSizeList[1]); # Match the items each time for each myFont in FontList # For every font in Global FontList begin # Random values for Sizes and Styles mySize := random(1,numFontSize); # Random # between 1 and the # of sizes SelectMenuItem(myFont,FontMenu[1],FontMenu[2]); # Select the font from the Font menu SelectMenuItem(fontSizeList[mySize],SizeMenu[1],SizeMenu[2]); # Select the size from the size menu if (numFontStyle) begin NumStyle := random(1,numFontStyle); # Random # between 1 and the # of styles LogStr("Choosing {NumStyle} font styles"); CurrentStyleList := fontStyleList; # Save copy of Global FontStyleList CurrentnumFontStyle := numFontStyle; # Save copy of number of style in FontStyleList for i:= 1 to NumStyle begin myStyle := random(1,CurrentnumFontStyle); # choose a random number between 1 and the number of styles available SelectMenuItem(CurrentStyleList[myStyle],StyleMenu[1],StyleMenu[2]); # Select the style from the style menu CurrentStyleList := RemoveItem(CurrentStyleList[myStyle],CurrentStyleList); # After selecting a Style remove it from available styles so we don't reselect it. CurrentnumFontStyle := CurrentnumFontStyle - 1; #Decrement number of styles available since we removed an item end; StylesSelected:= ""; # Initialize string containing styles chosen #### Collect all the checked styles if (StyleMenu[2] = "") # IF - it's not hierarchical StylesSelectedList := Collect [menuItem c:'' m:[menu t:StyleMenu[1]]]!; #see if it is checked else # Is Hierarchical StylesSelectedList := Collect[menuItem c:'' m:[menuitem t:StyleMenu[1] m:[menu t:StyleMenu[2]]]]!; #see if it is checked for each StyleItem in StylesSelectedList StylesSelected:= StylesSelected + " " + StyleItem.t; #if so, add to string end; else StylesSelected := ''; SizeSelected:= fontSizeList[mySize]; #Assign size chosen to variable TypeStr("{textStr} - {myFont} {SizeSelected} {StylesSelected}"); #type the text string, font, size and styles chosen ### For more than 1 line of text a new line must be selected if (NextLineKey = 0) #you want random move and click begin theWind := FindWindow(Specifier); if theWind begin windOrd := theWind.o; title := theWind.t; MoveRelativeToWindow('random','random',windOrd,2,inset); #move pointer to a random end; end; ### Cases of Keystrokes to move to next line if (NextLineKey = 1) SpecialKey(returnKey,"Return Key"); else if (NextLineKey = 2) SpecialKey(enterKey,"Enter Key"); else if (NextLineKey = 3) SpecialKey(downarrowKey,"Down Arrow Key"); else if (NextLineKey = 4) SpecialKey(tabKey,"Tab Key"); end; if (numTextstrings > 1) LogStr("Typed '{textStr}' {numTextstrings} times."); #send summary to output file end; # DoText() ######################################################################## # PageSetup( WhichDevice ) #======================================================================= # Author: KTA # Description: For PageSetup routines # Parameters: Nada # Returns: None #======================================================================= # History: # KTA 2/25/91 Created ######################################################################## task PageSetup(WhichDevice := "LaserWriter") begin if ( WhichDevice = "LaserWriter") begin SelectMenuItem("Page Setup", "File"); #To select Page SetUp… wait(1); SpecialKey(returnKey, 'Return Key'); #To Select the Default-'OK' wait(1); end; end; # PageSetup() ######################################################################## # Print() #======================================================================= # Author: KTA # Description: For Print routines # Parameters: Nada # Returns: None #======================================================================= # History: # KTA 8/19/91 Created ######################################################################## task Printer() begin if (global PrintTest) begin SelectMenuItem("Print", "File"); #To select Print wait(2); SpecialKey(returnKey, 'Return Key'); #To Select the Default-'OK' end; end; # Printer() ######################################################################### # IsNumber(whatAmI) #======================================================================== # Author: NJV # Description: This routine determine whether the input parameter is # a number or not. This could be done directly in-line, # but to avoid Developer's having to modify their code, # I updated this routine so that scripts will still work # properly unmodified. # Parameters: whatAmI - item to check # Returns: true - the parameter is a number # false - the parameter is not a number # Examples: IsNumber("Hello"); # Assumptions: None #======================================================================== # History: # NJV 5/22/90 Created # NJV 6/25/91 Now uses TypeOf() VU function ######################################################################### task IsNumber(whatAmI) begin return((TypeOf(whatAmI) = 'integer')); end; # IsNumber() ######################################################################### # PtInRect(thePoint,theRect) #======================================================================== # Author: NJV # Description: This routine determines whether or not thePoint # is contained within theRect (including borders). # Parameters: thePoint - a list of two integers # theRect - holds the coordinates of the rectangle. # Returns: true - point lies in the rectangle. # false - point does NOT lie in the rectangle. # Examples: isIt := PtInRect(thePoint,theRect). # Assumptions: None #======================================================================== # History: # NJV 9/18/90 Created ######################################################################### task PtInRect(thePoint,theRect) begin return( ((thePoint[1] >= theRect[1]) and (thePoint[1] <= theRect[3])) and ((thePoint[2] >= theRect[2]) and (thePoint[2] <= theRect[4])) ); end; ######################################################################### # CenterofScreenClick() #======================================================================= # Author: KTA # Description: Clicks in the center of main screen # Parameters: none # Returns: Nada #======================================================================= # History: # KTA 12/05/90 Added [m:True] to make sure the right screen ######################################################################### task CenterofScreenClick() begin Match[screen r:?x m:true]; w := ((x[3]-x[1])/2); h := ((x[4] - x[2])/2); move a:{w,h}; click; LogStr('Moved to the center of the screen and clicked'); end; # CenterofScreenClick() ######################################################################### # RemoveItem(Item,List) #======================================================================== # Author: KA & JM # Description: This routine was designed to remove items from lists. # Parameters: Item - Item to be removed from the list # List - any list # Returns: Newlist := if Item is removed from List # 0 := if Item is not contained in List #======================================================================== # History: # KA & JM 8/19/91 Created ######################################################################### task RemoveItem(Item,list) begin origList := List; # Save original list if (isMember(item,list)) # Is it item in list begin NumItems:= card(list); for WhichItem := 1 to NumItems begin if (list[WhichItem] = Item) begin Newlist := Remove(WhichItem, list); # Remove item from list liststring := ''; for numtimes := 1 to (Card(origList)-1) # Build String for output liststring := liststring + origList[numTimes] + ', '; liststring := liststring + origList[Card(origList)]; #println "The item '{item}' has been removed from the '{WhichItem}' position of list '∂{ {liststring} ∂}'"; return(Newlist); end; end; end; Else Return(0); end; # RemoveItem() ######################################################################### # ReplaceItem(ItemtoBeReplaced, ReplaceItem, List) #======================================================================== # Author: KA (x45604) # Description: This routine was designed to replace items in lists. # Parameters: ItemtoBeReplaced - Item to be replaced from the list # ReplaceItem - Item which will now be a part of the list # List - any list # Returns: Newlist := if ItemtoBeReplaced is replaced from List # 0 := if ItemtoBeReplaced is not contained in List #======================================================================== # History: # KA 9/11/91 Created ######################################################################### task ReplaceItem(ItemtoBeReplaced, ReplaceItem,List) begin origList := List; # Save original list if (isMember(ItemtoBeReplaced,list)) # Is it item in list begin NumItems:= card(list); for WhichItem := 1 to NumItems begin if (list[WhichItem] = ItemtoBeReplaced) begin Newlist := Replace(ReplaceItem,WhichItem, list); # replace item from list liststring := ''; for numtimes := 1 to (Card(origList)-1) # Build String for output liststring := liststring + origList[numTimes] + ', '; liststring := liststring + origList[Card(origList)]; #println "The item '{ItemtoBeReplaced}' has been replaced with '{ReplaceItem}'from the '{WhichItem}' position of list '∂{ {liststring} ∂}'"; return(Newlist); end; end; end; Else Return(0); end; # ReplaceItem() ######################################################################### # Timer(timeParam) #======================================================================= # Author: DM # Description: Calculates the time between two time descriptors # Parameters: timeParam - Specifier - what to return # 1 - return ({"{theHour}:{theSec}",theHour,theSec}); # 2 - return (("{theMonth}/{theDay}/{theYear}")) # 3 - return (theTime) - full descriptor # 4 - CurrentTime - formatted # Example: Timer(1); #======================================================================= # History: # DM 9/04/90 Created # KTA 7/25/91 Added Case 4 - Current time # JM 2/14/92 Fixed Timer(4) for hours between 12AM and 1AM # Add leading zeros for if theHour < 100 (1:00AM) ######################################################################### task Timer(timeParam:=1) begin theTime := match [time h:?theHour s:?theSec d:?theDay m:?theMonth y:?theYear]; if (timeParam = 1) begin return ({"{theHour}:{theSec}",theHour,theSec}); end; else if (timeParam = 2) begin return (("{theMonth}/{theDay}/{theYear}")); end; else if (timeParam = 3) begin return (theTime); end; else if (timeParam = 4) begin HourString := numToStr (theHour); while (Card(HourString) < 4) HourString := '0' + HourString; HourString := HourString[1] + HourString[2] + ':' + HourString[3] + HourString[4]; SecString := numToStr (theSec); if( Card(SecString) = 1) SecString := '0' + SecString; CurrentTime := HourString + ':' + SecString; Println "The current time is - ",CurrentTime; Return(CurrentTime); end; end; # Timer() ######################################################################### # ETime(time1, time2) #======================================================================= # Author: DM # Description: Calculates the time between two time descriptors # Parameters: time1 - initial time # time2 - end time # Returns: "{eh}:{em}:{es}" - Difference between the two # Example: ETime(time1, time2); #======================================================================= # History: # DM 9/04/90 Created ######################################################################### task ETime(time1, time2) begin h1:= 0; h2 := 0; m1:= 0; m2 := 0; t1 := time1.h; t2 := time2.h; s1 := time1.s; s2 := time2.s; if(t1 > t2) begin t1 := time2.h; t2 := time1.h; s1 := time2.s; s2 := time1.s; end; h1 := t1/100; # get h1 m1 := t1 mod 100; # get m1 h2 := t2/100; # get h2 m2 := t2 mod 100; # get m2 eh := h2-h1; em := m2-m1; # eh = elapsed hours, em = elapsed mins if(em<0) begin em := em + 60; eh := eh -1; end; es := s2 - s1; if(es<0) begin if (em>0) begin es := es + 60; em := em -1; end; else if (eh>0) begin es := es + 60; eh := eh - 1; em := 59; end; else begin es := -es; end; end; return ("{eh}:{em}:{es}"); end; # ETime() ######################################################################### # DoSpecialTest(WhichTest) #======================================================================= # Author: KTA # Description: Hook for any special tests all the Standard QuickLooks # Call this task 3 times. # Parameters: WhichTest - Scriptor defined tests. # Returns: Whatever you want. # Example: DoSpecialTest(1); #======================================================================= # History: # KTA 9/04/90 Created ######################################################################### task DoSpecialTest( WhichTest := 0) begin if ( WhichTest = 1 ) begin println; Timer(4); # Current time global startTime := Timer(3); Println "Starting the timer"; end; if (global Spectest) begin if ( WhichTest = 1 ) begin SelectMenuItem("Show Balloons"); end; if ( WhichTest = 2 ) begin LogStr("About to begin middle Special Tests"); SelectMenuItem("Print", "File"); SpecialKey(returnKey,"Return Key"); SpecialKey(returnKey,"Return Key"); Wait(5); SelectMenuItem("Print", "File"); SpecialKey(returnKey,"Return Key",2); SelectMenuItem("Hide Balloons"); end; end; end; # DoSpecialTest() task DoSpecTestsInitial() begin DoSpecialTest(1); end; task DoSpecTestsMiddle() begin DoSpecialTest(2); end; ######################################################################### # Scrapbook(requestElement,ccpFlag,pasteFlag) #======================================================================== # Author: KTA # Description: This routine will select the scrapbook, scroll to the # designated requestElement position, select Cut, Copy, Paste, # or Clear from the Edit menu, close the scrapbook if under System # 6.0.x, and then select Paste if the pasteFlag parameter is 1. # Parameters: requestElement - the element in the scrapbook to scroll to # ccpFlag - 1 for copy # 2 for cut # 3 for paste # 4 for clear # pasteFlag - 1 to paste after closing Scrapbook # 0 not to paste after closing Scrapbook # Returns: 0 - Couldn't complete operation # element - Scrapbook element that operation took place on # Examples: Scrapbook(2) will scroll the horizontal bar to the # second entry and then copy, close and paste. # Assumptions: That the scrollbars are present. That the string # 'Scrapbook' appear somewhere in the name #======================================================================== # History: # KTA 11/28/89 Created # KTA 5/14/90 handles its own scrollbars instead of ScrollWindow() # Checks for enabled scrollbars # MatchApp(0); for App verification # NJV 7/3/90 (x,y) parameters are now just (x) # added copyFlag - 1 if copy, 0 if cut # NJV 7/5/90 Added pasteFlag - 1 if paste, 0 if don't paste # Added error checking to assure requested scrapbook # element exists. # Added error checking to make sure Cut or Copy menu # item selection was successful - if not, routine # closes ScrapBook and aborts (returning 0). # NJV/KTA 7/13/90 took out wait # added while ! match [window t:'Scrapbook' o:1]!); # NJV/KTA 7/17/90 changed copyFlag to ccpFlag for paste and clear # bug fix from previous re-work # NJV 10/9/90 If 7.0, calls LaunchTwitch instead of closing Scrapbook # NJV 11/27/90 Updated documentation # KTA 1/9/91 Added scrap := 1 to 4 # KTA 1/24/91 Took out a unneeded comment about checking in the Apple Menu # KTA 1/30/91 put in fix for 7.0ß4 where sound button is control [1] # KTA 2/18/91 Took out integration - May put this in the Integrate.lib # KTA 2/25/91 LaunchTwitch PreviousApp if can launch Scrapbook # KTA 9/31/91 Took out patch for sound # KTA 4/16/92 6.0x Support # KTA 4/20/92 Changed title to ordinality for intl ######################################################################### task Scrapbook(requestElement,ccpFlag := 1,pasteFlag := 1) begin Global isSys7,Integration; temp := Integration; Integration := 0; #To turn off global Integration - KTA println "=========================================================="; LogStr("Performing Scrapbook DA test."); if (ccpFlag > 4) ccpFlag := 1; # old default is copy If(LaunchTwitch('Scrapbook')) begin scBook := match [window t:'Scrapbook' o:1]!; if(scBook.k[1].t = 'Play Sound') #put in fix for 7.0ß4 where sound button is control [1] SkrollBar := scBook.k[2]; else SkrollBar := scBook.k[1]; status := SkrollBar.s; if (status <> { 0, -1 }) # if scrollbar is enabled... begin error := 0; # no errors yet elementCount := status[2] + 1; # elementCount = number of scrapbook elements currentElement := status[1] + 1; # currentElement = current position in Scrapbook newCount := elementCount + 1; if (requestElement>elementCount) # if position is greater than total elements in Scrapbook.. begin if (ccpFlag = 1) LogStr("!@#$% Scrapbook entry {requestElement} does not exist! - Copying entry {currentElement} of {elementCount}"); else if (ccpFlag = 3) LogStr("!@#$% Scrapbook entry {requestElement} does not exist! - Pasting to entry {currentElement} of {newCount}"); else begin LogStr("!@#$% Can∂'t Cut/Clear - Scrapbook entry {requestElement} does not exist! Closing Scrapbook!"); error := 1; # don't clear or cut if requested item not there end; end; else # we've got a valid Scrapbook entry begin scroll SkrollBar a:{requestElement,elementCount}; match [scrollbar s:?status]!; currentElement := status[1] + 1; # currentElement = current position in Scrapbook LogStr("Scrolled to item {currentElement} of {elementCount} of the ScrapBook"); wait(1); end; if (not error) begin if (ccpFlag = 1) begin # Copy Item if (not SelectMenuItem(4, 3)) # error - couldn't copy error := 1; # prepare to abort end; else if (ccpFlag = 2) begin if (not SelectMenuItem(3, 3)) # error - couldn't cut error := 1; # prepare to abort end; else if (ccpFlag = 3) begin if (not SelectMenuItem(5, 3)) # error - couldn't paste error := 1; # prepare to abort else LogStr("Pasted to entry {currentElement} of {newCount}"); end; else if (ccpFlag = 4) begin if (not SelectMenuItem(6, 3)) # error - couldn't clear error := 1; # prepare to abort end; end; wait(2); Integration := temp; #To reset the integration global - KTA if (isSys7) LaunchTwitch(Global PrevAppTitle); else # 6.0 Support since process list is different begin temp2 := global Appverify; Appverify := 0; CloseWindow(,,'ScrapBook'); # close ScrapBook Appverify := temp2; MatchApp(0); end; if (error) return(0); if (pasteFlag) begin # if we're supposed to paste back into document, do it wait(3); if (SelectMenuItem(5, 3)) begin println "=========================================================="; return(1); end; end; return(currentElement); # everything went OK end; else begin LogStr('!@#$% The horizontal scroll bar was not enabled to scroll'); closeWindow(); return(0); end; end; else begin LogStr("Couldn't open the ScrapBook for some reason"); if (Global isSys7) LaunchTwitch(Global PrevAppTitle); return(0); end; end; # Scrapbook() ######################################################################### # Quit(OverWrite, DocName) #======================================================================= # Author: KTA # Description: Will turn off the Application Verification scheme, Select # the Quit menu item, check whether or not to save changes, # then reset the App verification scheme to its previous state. # Parameters: OverWrite 1 - Save changes. # 0 - Don't save changes. # DocName - The string that will be used to save the document # HowQuit 1 - Select "Quit" from File Menu # 2 - Type Cmd-Q to quit # Returns: Nada #======================================================================= # History: # KA 8/23/90 Created # NJV 11/25/90 Added KeepScrapOpen parameter to bypass KAs assumption # that ScrapBook is open (fix in scrapbook for 6.0 world). # KTA 12/18/90 Took out KeepScrapOpen parameter-auto close Scrap # KTA 1/8/91 Moved endTime # KTA 1/9/91 Added HowQuit # KTA 2/18/91 Added While(CheckYesNo) ######################################################################### task Quit(OverWrite :=1,DocName:="",HowQuit :=1) begin temp := global Appverify; AppVerify := 0; global startTime; if (HowQuit = 1) SelectMenuItem('Quit','File'); #Quit MenuItem else if (HowQuit = 2) keyEq('q'); #Key Equiv 'q' while(checkYesNo(overwrite)) begin If(overWrite) if (match[button t:"Save"]!) or (match[button t:"OK"]!) # If SF dialog comes up # NameOk(DocName,true); wait(3); end; endTime := Timer(3); if (isUndefined(startTime)) elTime := "not calculated because no one bothered to start the timer!!!)"; else elTime := ETime(startTime,endTime); println "Total Elapsed time was {elTime}"; wait(1); if match[window o:1 t:"Scrapbook"]! closeWindow(,,"Scrapbook"); wait(2); KeyEq('w',2); AppVerify := temp; MatchApp(); println; end; # Quit()